📄 wgl_32doc.cpp
字号:
m_strRecordPath += _T(drive);
m_strRecordPath += _T(dir);
dir[lstrlen(dir)-1]=0x00;
char *ptr = strrchr(dir, '\\')+1;
sprintf(m_strRecordID.GetBuffer(_MAX_DIR), "%s", ptr);
m_strRecordID.ReleaseBuffer();
if( !OpenRelateConFig( cfgFileName ) )
{
bReadError = TRUE;
AfxMessageBox(_T("Read config file ERROR !"), MB_OK|MB_ICONEXCLAMATION);
return;
}
if( !ReadThisDataFile( ar ) )
{
bReadError = TRUE;
AfxMessageBox(_T("Read data file ERROR !"), MB_OK|MB_ICONEXCLAMATION);
return;
}
if(!SetInitShowStatus()) return;
bReadError = FALSE;
m_FaultLineNo = ((CWgl_32App*)AfxGetApp())->m_FaultLineNo;
m_strFaultPhase = ((CWgl_32App*)AfxGetApp())->m_strFaultPhase;
FFTPoints = ((CWgl_32App*)AfxGetApp())->FFTPoints;
fFaultJL = ((CWgl_32App*)AfxGetApp())->fFaultJL;
m_strReportFile = ((CWgl_32App*)AfxGetApp())->m_strReportFile;
m_strFaultFile = ((CWgl_32App*)AfxGetApp())->m_strFaultFile;
AnaError = ((CWgl_32App*)AfxGetApp())->AnaError;
if(m_FaultLineNo == -1)
return;
for(int i=0; i<8; i++)
{
m_strFaultLineName[i] = ((CWgl_32App*)AfxGetApp())->m_strFaultLineName[i];
for(UINT j=0; j<=FFTPoints; j++)
{
Value[i][j] = ((CWgl_32App*)AfxGetApp())->Value[i][j];
}
}
}
}
/////////////////////////////////////////////////////////////////////////////
// CWgl_32Doc diagnostics
#ifdef _DEBUG
void CWgl_32Doc::AssertValid() const
{
CDocument::AssertValid();
}
void CWgl_32Doc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
int CWgl_32Doc::GetVScrollPos()
{
int k = 0;
for(int i = 0; i < m_ViewChannel; i++)
if(m_pChannelIndex[i].bShow) k++;
return k;
}
void CWgl_32Doc::SwapChannelInform(int Num1,int Num2)
{
COLORREF Color = m_pChannelIndex[Num1].Color;
char bShow = m_pChannelIndex[Num1].bShow;
WORD No = m_pChannelIndex[Num1].No;
char nNumb = m_pChannelIndex[Num1].nNumb;
WORD *pSub = m_pChannelIndex[Num1].pSub;
double YFactor = m_pChannelIndex[Num1].YFactor;
m_pChannelIndex[Num1].Color = m_pChannelIndex[Num2].Color;
m_pChannelIndex[Num1].bShow = m_pChannelIndex[Num2].bShow;
m_pChannelIndex[Num1].No = m_pChannelIndex[Num2].No;
m_pChannelIndex[Num1].nNumb = m_pChannelIndex[Num2].nNumb;
m_pChannelIndex[Num1].pSub = m_pChannelIndex[Num2].pSub;
m_pChannelIndex[Num1].YFactor = m_pChannelIndex[Num2].YFactor;
m_pChannelIndex[Num2].Color = Color;
m_pChannelIndex[Num2].bShow = bShow;
m_pChannelIndex[Num2].No = No;
m_pChannelIndex[Num2].nNumb = nNumb;
m_pChannelIndex[Num2].pSub = pSub;
m_pChannelIndex[Num2].YFactor = YFactor;
}
BOOL CWgl_32Doc::CopyChannelInform(int Num,int NumS)
{
int k = m_pChannelIndex[Num].nNumb;
WORD *pSub = m_pChannelIndex[Num].pSub;
for(int i=0; i<k; i++)
if(pSub[i] == NumS) return FALSE;
WORD *pSubA = new WORD[k+1];
for(i=0; i<k; i++)
pSubA[i] = pSub[i];
pSubA[i] = NumS;
m_pChannelIndex[Num].pSub = pSubA;
if(pSub) delete[] pSub;
m_pChannelIndex[Num].nNumb += 1;
return TRUE;
}
BOOL CWgl_32Doc::DeltChannelInform(int Num,int NumS)
{
int k = m_pChannelIndex[Num].nNumb;
if( k<=0 ) return FALSE;
WORD *pSub = m_pChannelIndex[Num].pSub;
int l = -1;
for(int i=0; i<k; i++)
if(pSub[i] == NumS)
{
l = i;
break;
}
if( l == -1 ) return FALSE;
if(k > 1)
{
WORD *pSubA = new WORD[k-1];
int j=0;
for(i=0; i<k; i++)
{
l = pSub[i];
if( l == NumS) continue;
pSubA[j++] = l;
}
m_pChannelIndex[Num].pSub = pSubA;
}
else
{
m_pChannelIndex[Num].pSub = NULL;
m_pChannelIndex[Num].nNumb = 0;
}
if(pSub) delete[] pSub;
if(m_pChannelIndex[Num].nNumb > 1)
m_pChannelIndex[Num].nNumb -= 1;
return TRUE;
}
BOOL CWgl_32Doc::DeltChannelInform(int Number)
{
if(mNumViewChannel <= 1)
return FALSE;
if(m_pChannelIndex[Number].bShow==0)
return FALSE;
m_pChannelIndex[Number].bShow = 0;
if(m_ViewChannelMax == Number)
while(m_pChannelIndex[m_ViewChannelMax].bShow == 0)
m_ViewChannelMax--;
if(m_ViewChannelMin == Number)
while(m_pChannelIndex[m_ViewChannelMin].bShow == 0)
m_ViewChannelMin++;
if(m_ViewChannel == Number)
if(m_ViewChannel < m_ViewChannelMax)
while(m_pChannelIndex[m_ViewChannel].bShow == 0)
m_ViewChannel++;
else
while(m_pChannelIndex[m_ViewChannel].bShow == 0)
m_ViewChannel--;
mNumViewChannel--;
return TRUE;
}
BOOL CWgl_32Doc::RelocalShortNode(CStringArray& List,CString strShow)
{
ShortNodeNum = List.GetSize();
if(m_pShortNode)
delete[] m_pShortNode;
m_pShortNode = new ShortNode[ShortNodeNum];
for(int i=0; i<ShortNodeNum; i++)
{
unsigned long tul;
CString strTemp = List[i];
sscanf(strTemp,"%lu",&tul);
m_pShortNode[i].lend = tul;
if(strTemp.Find(strShow)>-1)
m_pShortNode[i].bShow = 1;
else
m_pShortNode[i].bShow = 0;
}
m_pShortNode[i-1].bShow = 1;
return TRUE;
}
BOOL CWgl_32Doc::SetNewSegment(int nx1, int nx2)
{
unsigned long Index1,Index2;
int i,i1,i2;
if(nx1 > nx2)
{ i=nx1; nx1=nx2; nx2=i; }
GetHNumIndex(nx1,Index1);
GetHNumIndex(nx2,Index2);
AdjustSampIndex(Index1,FALSE);
AdjustSampIndex(Index2,FALSE);
if(Index1 == Index2)
return TRUE;
if(Index1 == EndSampNum-1)
Index1 = EndSampNum;
if(Index2 == EndSampNum-1)
Index2 = EndSampNum;
i1 = i2 = -1;
for(i=0; i<ShortNodeNum; i++)
{
if(m_pShortNode[i].lend <= Index1) i1 = i;
if(m_pShortNode[i].lend <= Index2) i2 = i;
}
int Inc = 0;
BOOL bInc1,bInc2;
bInc1 = bInc2 = TRUE;
if(m_pShortNode[i1].lend == Index1) bInc1 = FALSE;
if(m_pShortNode[i2].lend == Index2) bInc2 = FALSE;
ShortNode *pShortNode = new ShortNode[ShortNodeNum+2];
for(i=0; i<=i1; i++)
{
pShortNode[i].lend = m_pShortNode[i].lend;
pShortNode[i].bShow = m_pShortNode[i].bShow;
}
if(!bInc1)
pShortNode[i1].bShow = 0;
if(bInc1)
{
i1 ++;
pShortNode[i1].lend = Index1;
pShortNode[i1].bShow = 0;
}
i1 ++;
pShortNode[i1].lend = Index2;
pShortNode[i1].bShow = 1;
if(!bInc2)
pShortNode[i1].bShow = m_pShortNode[i2].bShow;
i = i2+1;
while( i < ShortNodeNum )
{
i1 ++;
pShortNode[i1].lend = m_pShortNode[i].lend;
pShortNode[i1].bShow = m_pShortNode[i].bShow;
i ++;
}
delete[] m_pShortNode;
m_pShortNode = pShortNode;
ShortNodeNum = i1+1;
return FALSE;
}
unsigned long CWgl_32Doc::GetShowHRange(unsigned long& NumHide)
{
NumHide = 0;
unsigned long range = 0;
for(int i=0; i<ShortNodeNum-1; i++)
if(m_pShortNode[i].bShow)
range = range+m_pShortNode[i+1].lend-m_pShortNode[i].lend;
else
NumHide = NumHide+ShortWidth;
return range;
}
extern int intINT(double);
// Calculate the Scrollbar Position, nPos is the REAL sample index
unsigned int CWgl_32Doc::GetHNumIndex(unsigned long nPos)
{
int xlstart = 0;
unsigned int tul = 0;
if( nPos == 0 ) return 0;
while(xlstart<ShortNodeNum-1)
{
if(m_pShortNode[xlstart].bShow)
{
int l=m_pShortNode[xlstart+1].lend-m_pShortNode[xlstart].lend;
l = intINT(l*m_XSizeFactor);
if(m_pShortNode[xlstart+1].lend>=nPos)
{
tul += intINT((nPos-m_pShortNode[xlstart].lend)*m_XSizeFactor);
break;
}
tul += l;
}
else
{
if(m_pShortNode[xlstart+1].lend>nPos)
{
if(m_pShortNode[xlstart].lend==nPos)
{
tul += ShortWidth;
break;
}
tul += ShortWidth/2;
break;
}
tul += ShortWidth;
}
xlstart ++;
}
return tul;
}
// Calculate the REAL sample index, xPos is the Scrollbar Position
unsigned long CWgl_32Doc::GetHNumIndex(unsigned int xpos)
{
unsigned int range = 0;
if( xpos == 0 ) return 0;
for(int i=0; i<ShortNodeNum-1; i++)
{
unsigned int l;
char bShow = m_pShortNode[i].bShow;
if( bShow )
{
l = m_pShortNode[i+1].lend-m_pShortNode[i].lend;
l = intINT(l*m_XSizeFactor);
}
else
l = ShortWidth;
if(range+l >= xpos)
if(bShow)
{
l = intINT((xpos-range)/m_XSizeFactor);
range = m_pShortNode[i].lend+l;
break;
}
else
if(range+l > xpos)
{
range = m_pShortNode[i].lend+1;
break;
}
else
{
range = m_pShortNode[i].lend;
break;
}
range = range+l;
}
return (unsigned long)range;
}
//According the Sample Point Index Adjust this Point Index
void CWgl_32Doc::AdjustSampIndex(unsigned long& Index,BOOL bIncDec)
{
int xlstart = 0;
while(xlstart<ShortNodeNum && m_pShortNode[xlstart].lend<=Index)
xlstart ++;
xlstart--;
if(m_pShortNode[xlstart].bShow || m_pShortNode[xlstart].lend==Index)
{
if(xlstart == ShortNodeNum-1)
Index = EndSampNum-1;
return;
}
if(bIncDec && xlstart<ShortNodeNum-1)
xlstart ++;
Index = m_pShortNode[xlstart].lend;
}
//According the position of the Mouse Pressed
//calculate the nearest sample point index
void CWgl_32Doc::GetHNumIndex(int xpos,unsigned long& Index)
{
int xcStart = 0;
int xlstart = 0;
Index = PageFromSampNum;
unsigned long lle,lli=PageFromSampNum;
while(xlstart<ShortNodeNum && m_pShortNode[xlstart].lend<=lli)
xlstart ++;
xlstart--;
while(xlstart < ShortNodeNum)
{
while(xlstart < ShortNodeNum && m_pShortNode[xlstart].bShow==0)
{
if(lli == m_pShortNode[xlstart].lend)
{
xcStart += ShortWidth;
if(xcStart >= xpos && xlstart+1 < ShortNodeNum)
{
Index = m_pShortNode[xlstart+1].lend;
return;
}
}
else
{
xcStart += ShortWidth/2;
if(xcStart >= xpos && xlstart+1 < ShortNodeNum)
{
Index = m_pShortNode[xlstart+1].lend;
return;
}
}
xlstart++;
lli = m_pShortNode[xlstart].lend;
}
if(xlstart == ShortNodeNum-1)
return;
lle = m_pShortNode[xlstart+1].lend;
int ti = intINT((lle-lli)*m_XSizeFactor);
if(xcStart+ti >= xpos)
{
Index = lli+intINT((xpos-xcStart)/m_XSizeFactor);
return;
}
xlstart ++;
lli = lle;
xcStart = xcStart+ti;
}
}
//According the sample point index calculate the displayed position
void CWgl_32Doc::GetHNumPosit(int& xpos,unsigned long index)
{
xpos = 0;
if(index < PageFromSampNum)
{ xpos = -1; return; }
if(index == PageFromSampNum) return;
int xlstart = 0;
unsigned long lle,lli=PageFromSampNum;
while(xlstart<ShortNodeNum && m_pShortNode[xlstart].lend<=lli)
xlstart ++;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -