📄 process.cpp
字号:
for (int nBook = 0; nBook < GetSize(); nBook++) {
CBook* pSrcBook = &(ElementAt(nBook));
CBook* pDstBook = &(pDst->ElementAt(nBook));
pDstBook->m_CurrChapter = pSrcBook->m_CurrChapter;
for (int nChapter = 0; nChapter < pSrcBook->GetSize(); nChapter++) {
CChapter* pSrcChapter = &(pSrcBook->ElementAt(nChapter));
CChapter* pDstChapter = &(pDstBook->ElementAt(nChapter));
pDstChapter->m_CurrFunc = pSrcChapter->m_CurrFunc;
}
}
}
BOOL CSubProcess::PresentBase(CString name)
{
for (int i=0; i<GetSize(); i++) {
if (ElementAt(i).PresentBase(name)) return TRUE;
}
return FALSE;
}
CFunc CSubProcess::GetCurrentFunction(CFunc pairFunc) {
if ((m_CurrBook < 0) ||
(m_CurrBook >= GetSize())) return _T("");
return GetAt(m_CurrBook).GetCurrentFunction(pairFunc);
}
void CSubProcess::SetCurrentFunction(int nBook, int nChapter, CFunc func) {
SetCurrentBook(nBook);
if (m_CurrBook >= 0 && m_CurrBook < GetSize())
ElementAt(m_CurrBook).SetCurrentFunction(nChapter, func);
}
int CSubProcess::GetCurrentChapter() {
if ((m_CurrBook < 0) ||
(m_CurrBook >= GetSize())) return -1;
return GetAt(m_CurrBook).GetCurrentChapter();
}
void CSubProcess::SetCurrentChapter(int nBook, int nChapter) {
SetCurrentBook(nBook);
if (m_CurrBook >= 0 && m_CurrBook < GetSize())
ElementAt(m_CurrBook).SetCurrentChapter(nChapter);
}
void CSubProcess::SetCurrentBook(int nBook) {
if ((nBook >= 0) && (nBook < GetSize()))
m_CurrBook = nBook;
else if (GetSize() > 0)
m_CurrBook = 0;
else
m_CurrBook = -1;
}
int CSubProcess::GetFunctionsWithBase(CString baseName, CFuncList& funcList)
{
funcList.RemoveAll();
int result = 0;
for (int i=0; i<GetSize(); i++) {
result += ElementAt(i).GetFunctionsWithBase(baseName, funcList);
}
return result;
}
///////////////////////////////////////////////////////////////////////
// CBook class implementation
// class CBook provides classification for IPP library book.
// Book consists of chapters.
// Chapters are shown in the middle column of Process Dialog sheet
// and books are shown in the left column of Process Dialog sheet
///////////////////////////////////////////////////////////////////////
BOOL CBook::InitFunctions(CFuncList* pFuncList)
{
m_CurrChapter = 0;
BOOL result = FALSE;
for (int i=0; i<GetSize(); i++) {
if (ElementAt(i).InitFunctions(pFuncList)) result = TRUE;
}
return result;
}
void CBook::CopyFunctions(CBook* pSrc)
{
for (int i = 0; i < GetSize(); i++) {
ElementAt(i).CopyFunctions(&(pSrc->ElementAt(i)));
}
}
BOOL CBook::PresentBase(CString name)
{
for (int i=0; i<GetSize(); i++) {
if (ElementAt(i).PresentBase(name)) return TRUE;
}
return FALSE;
}
int CBook::GetFuncCount()
{
int result = 0;
for (int nChapter=0; nChapter < GetSize(); nChapter++) {
result += (int)GetAt(nChapter).GetCount();
}
return result;
}
BOOL CBook::ApplyVector(CVector* pVec)
{
BOOL result = FALSE;
for (int i=0; i<GetSize(); i++) {
if (ElementAt(i).ApplyVector(pVec)) result = TRUE;
}
return result;
}
BOOL CBook::ApplyFilter(const CFilter* pFilter)
{
BOOL result = FALSE;
for (int i=0; i<GetSize(); i++) {
if (ElementAt(i).ApplyFilter(pFilter)) result = TRUE;
}
return result;
}
CFunc CBook::GetCurrentFunction(CFunc pairFunc) {
if ((m_CurrChapter < 0) ||
(m_CurrChapter >= GetSize())) return _T("");
return GetAt(m_CurrChapter).GetCurrentFunction(pairFunc);
}
void CBook::SetCurrentFunction(int nChapter, CFunc func) {
SetCurrentChapter(nChapter);
if ((m_CurrChapter >= 0) && (m_CurrChapter < GetSize()))
ElementAt(m_CurrChapter).SetCurrentFunction(func);
}
void CBook::SetCurrentChapter(int nChapter) {
if (nChapter < 0 || nChapter >= GetSize())
nChapter = GetSize() ? 0 : -1;
if ((nChapter >= 0) && (GetAt(nChapter).GetCount() == 0)) {
nChapter = -1;
for (int n=0; n < GetSize(); n++) {
if (GetAt(n).GetCount()) {
nChapter = n;
break;
}
}
}
m_CurrChapter = nChapter;
}
int CBook::GetFunctionsWithBase(CString baseName, CFuncList& funcList)
{
int result = 0;
for (int i=0; i<GetSize(); i++) {
result += ElementAt(i).GetFunctionsWithBase(baseName, funcList);
}
return result;
}
///////////////////////////////////////////////////////////////////////
// CChapter class implementation
// class CChapter provides classification for IPP library chapter.
// Chapter consists of functions.
// Functions are shown in the right column of Process Dialog sheet
// and chapters are shown in the middle column of Process Dialog sheet
///////////////////////////////////////////////////////////////////////
int CChapter::InitFunctions(CFuncList* pFuncList)
{
RemoveAll();
POSITION pos = pFuncList->GetHeadPosition();
while (pos) {
CFunc func = pFuncList->GetNext(pos);
if (PresentBase(func.BaseName())) AddTail(func);
}
return (int)GetCount();
}
void CChapter::CopyFunctions(CChapter* pSrc)
{
RemoveAll();
POSITION pos = pSrc->GetHeadPosition();
while (pos) {
AddTail(pSrc->GetNext(pos));
}
}
BOOL CChapter::PresentBase(CString name)
{
POSITION pos = m_NameList.GetHeadPosition();
while (pos) {
if (name == m_NameList.GetNext(pos))
return TRUE;
}
return FALSE;
}
int CChapter::ApplyVector(CVector* pVec)
{
POSITION pos = GetHeadPosition();
while (pos) {
POSITION delPos = pos;
CFunc func = GetNext(pos);
if (!func.Valid(pVec)) {
RemoveAt(delPos);
}
}
return (int)GetCount();
}
int CChapter::ApplyFilter(const CFilter* pFilter)
{
if (!pFilter) return TRUE;
POSITION pos = GetHeadPosition();
while (pos) {
POSITION delPos = pos;
if (!pFilter->Apply(GetNext(pos))) {
RemoveAt(delPos);
}
}
return (int)GetCount();
}
enum { M_BASE, M_DST, M_I, M_R, M_S};
static BOOL select(CFuncList& funcList, CFunc currFunc, int mFlag)
{
CFuncList tmpList;
POSITION pos = funcList.GetHeadPosition();
while (pos) {
CFunc func = funcList.GetNext(pos);
switch (mFlag) {
case M_BASE: if (func.BaseName() == currFunc.BaseName()) break;
continue;
case M_DST: if (func.DstType() == currFunc.SrcType()) break;
continue;
case M_I: if (func.Inplace() == currFunc.Inplace()) break;
continue;
case M_R: if (func.Roi() == currFunc.Roi()) break;
continue;
case M_S: if (func.Scale() == currFunc.Scale()) break;
continue;
default: continue;
}
tmpList.AddTail(func);
}
if (tmpList.GetCount() == 0) return FALSE;
funcList.RemoveAll();
funcList.AddTail(&tmpList);
return TRUE;
}
CFunc CChapter::GetCurrentFunction(CFunc pairFunc)
{
if (GetCount() == 0) return _T("");
pairFunc = pairFunc.GetPair();
if (Find(pairFunc)) {
return pairFunc;
}
if (Find(m_CurrFunc)) return m_CurrFunc;
CFuncList tmpList;
tmpList.AddTail(this);
if (!select(tmpList,m_CurrFunc, M_BASE)) return _T("");
select(tmpList,m_CurrFunc, M_DST);
select(tmpList,m_CurrFunc, M_I);
select(tmpList,m_CurrFunc, M_R);
select(tmpList,m_CurrFunc, M_S);
return tmpList.GetAt(tmpList.GetHeadPosition());
}
void CChapter::SetCurrentFunction(CFunc func)
{
m_CurrFunc = func;
}
int CChapter::GetFunctionsWithBase(CString baseName, CFuncList& funcList)
{
if (!PresentBase(baseName)) return 0;
int result = 0;
POSITION pos = GetHeadPosition();
while (pos) {
CFunc func = GetNext(pos);
if (func.BaseName() == baseName) {
funcList.AddTail(func);
result++;
}
}
return result;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -