?? func.cpp
字號:
return dst;
}
void CFunc::GetTypes(ppType& src1, ppType& src2,
ppType& dst1, ppType& dst2) const
{
CMyString sBase, sType1, sType2, sType3, sDescr;
ParseFunction(sBase, sType1, sType2, sType3, sDescr);
if (sType1.IsEmpty())
throw _T("Bad function type");
src1 = StringToType(sType1);
src2 = StringToType(sType2);
dst1 = StringToType(sType3);
dst2 = dst1;
UpdateTypes(src1, src2, dst1, dst2);
}
static CMyString firstChanStr(CMyString& descr)
{
CMyString numStr = _T("1234");
int index = descr.Find(_T("C"));
int iP = descr.Find(_T("P"));
int len = 0;
CMyString chanStr = _T("");
if ((iP >= 0) && (index < 0 || (iP < index))) index = iP;
if ((index < 0) ||
(descr.GetLength() == index + 1) ||
(!numStr.Found(descr[index + 1]))) {
len = 0;
} else {
len = 2;
if ((index > 0) && (descr[index - 1] == 'A')) {
index--;
len++;
}
}
CMyString str = descr.Mid(index,len);
descr = descr.Mid(index + len);
return str;
}
static int numChannels(CMyString str)
{
if (str.IsEmpty()) return 0;
CMyString numStr((str[0] == 'A') ? str[2] : str[1]);
int num = _ttoi(numStr);
if (num > 4) num = 0;
return num;
}
static BOOL alphaChannel(CMyString str)
{
if (str.IsEmpty()) return 0;
return str[0] == 'A';
}
static BOOL planeChannel(CMyString str)
{
if (str.IsEmpty()) return 0;
_TCHAR symb = (str[0] == 'A') ? str[1] : str[0];
return symb == 'P';
}
void CFunc::GetChannelsName(CMyString& src, CMyString& dst) const
{
src = dst = _T("");
CMyString sDescr = DescrName();
src = firstChanStr(sDescr);
dst = firstChanStr(sDescr);
if (dst.IsEmpty()) dst = src;
}
void CFunc::GetChannels(int& src, int& dst) const
{
src = dst = 0;
CMyString sDescr = DescrName();
CMyString srcStr = firstChanStr(sDescr);
CMyString dstStr = firstChanStr(sDescr);
src = numChannels(srcStr);
if (dstStr.IsEmpty())
dst = src;
else
dst = numChannels(dstStr);
UpdateChannels(src, dst);
}
void CFunc::GetPlanes(BOOL& src, BOOL& dst) const
{
src = dst = FALSE;
CMyString sDescr = DescrName();
CMyString srcStr = firstChanStr(sDescr);
CMyString dstStr = firstChanStr(sDescr);
src = planeChannel(srcStr);
if (dstStr.IsEmpty())
dst = src;
else
dst = planeChannel(dstStr);
if (!src && !dst && sDescr.Found(_T("P")))
src = dst = TRUE;
UpdatePlanes(src,dst);
}
void CFunc::GetAlpha(BOOL& src, BOOL& dst) const
{
src = dst = FALSE;
CMyString sDescr = DescrName();
CMyString srcStr = firstChanStr(sDescr);
CMyString dstStr = firstChanStr(sDescr);
src = alphaChannel(srcStr);
if (dstStr.IsEmpty())
dst = src;
else
dst = alphaChannel(dstStr);
}
CString CFunc::InvBase() const
{
CString baseName = BaseName();
int iFwd = baseName.Find(_T("Fwd"));
int iInv = baseName.Find(_T("Inv"));
if (iFwd >= 0)
baseName = baseName.Left(iFwd) + _T("Inv") + baseName.Mid(iFwd + 3);
if (iInv >= 0)
baseName = baseName.Left(iInv) + _T("Fwd") + baseName.Mid(iInv + 3);
int iEmph = baseName.Find(_T("_"));
CString startName;
if (iEmph > 0) {
startName = baseName.Left(iEmph + 1);
baseName = baseName.Mid(iEmph + 1);
}
int iTo = baseName.Find(_T("To"));
if (iTo < 0) return startName + baseName;
baseName = baseName.Mid(iTo + 2) + _T("To") + baseName.Left(iTo);
return startName + baseName;
}
CFunc CFunc::FuncWithBase(CMyString baseName) const
{
CFunc func = Prefix() + baseName + _T("_") + TypeName();
if (!DescrName().IsEmpty())
func += _T("_") + DescrName();
return func;
}
CFunc CFunc::FuncWithBase_InvType(CMyString baseName) const
{
CMyString sBase, sType1, sType2, sType3, sDescr;
ParseFunction(sBase, sType1, sType2, sType3, sDescr);
CFunc func = Prefix() + baseName + _T("_");
if (sType1 == sType3)
func += sType1 ;
else
func += sType3 + sType1 ;
if (!sDescr.IsEmpty())
func += _T("_") + sDescr;
return func;
}
CFunc CFunc::FuncWithBase_InvChannels(CMyString baseName) const
{
CMyString sBase, sType, sChan1, sChan2, sDescr;
ParseFunction(sBase, sType, sDescr);
if (sDescr.IsEmpty())
return Prefix() + baseName + _T("_") + sType;
sChan1 = firstChanStr(sDescr);
sChan2 = firstChanStr(sDescr);
CFunc func = Prefix() + baseName + _T("_") + sType + _T("_");
if (sChan2.IsEmpty())
func += sChan1 ;
else
func += sChan2 + sChan1 ;
func += sDescr;
return func;
}
CMyString CFunc::VecName(int vecPos, int usedVectors) const
{
CMyString src, src2, dst, dst2;
GetVecNames(src, src2, dst, dst2, usedVectors);
switch (vecPos) {
case VEC_SRC: return src;
case VEC_SRC2: return src2;
case VEC_DST: return dst;
case VEC_DST2: return dst2;
case VEC_MASK: return _T("Mask");
}
return _T("");
}
void CFunc::GetVecNames(CMyString& src, CMyString& src2,
CMyString& dst, CMyString& dst2,
int usedVectors) const
{
src = _T(""); src2 = _T(""); dst = _T(""); dst2 = _T("");
if (usedVectors & VEC_SRC2) {
if (Inplace()) {
src = _T("Src"); src2 = _T("SrcDst");
} else {
src = _T("Src1"); src2 = _T("Src2");
}
} else {
if (Inplace()) src = _T("SrcDst");
else src = _T("Src");
}
if (usedVectors & VEC_DST2) {
dst = _T("Dst1"); dst2 = _T("Dst2");
} else {
dst = _T("Dst");
}
UpdateVecNames(src,src2,dst,dst2,usedVectors);
}
////////////////////////////////////////////////////////////////////
CFuncList::CFuncList()
{
m_position = NULL;
m_baseName = _T("");
m_pOutstandList = NULL;
}
CFuncList::~CFuncList()
{
}
void CFuncList::CreateFuncList(int idx)
{
if (pGlobalFuncList == NULL) return;
if (idx >= pGlobalFuncList->GetSize()) return;
AddTail(pGlobalFuncList->ElementAt(idx));
SetOutstandList(idx);
m_position = GetHeadPosition();
}
POSITION CFuncList::Find(LPCTSTR funcName, POSITION pos) const
{
if (pos == NULL) pos = GetHeadPosition();
else GetNext(pos);
while (pos) {
POSITION curPos = pos;
if (GetNext(pos) == funcName) return curPos;
}
return NULL;
}
int CFuncList::SubtractThisList(CStringList& rList)
{
POSITION rPos = rList.GetHeadPosition();
while (rPos) {
POSITION tPos = rPos;
CString tName = rList.GetNext(rPos);
POSITION fPos = GetHeadPosition();
while (fPos) {
if (tName == GetNext(fPos)) {
rList.RemoveAt(tPos);
break;
}
}
}
return (int)GetCount();
}
int CFuncList::SetOutstandList(int idx)
{
CFuncList dirList;;
DEMO_APP->GetDirector()->GetFunctions(dirList, idx);
if (m_pOutstandList) delete m_pOutstandList;
m_pOutstandList = new CFuncList;
POSITION pos = GetHeadPosition();
while (pos) {
POSITION delPos = pos;
CFunc func = GetNext(pos);
if (func.Find(_T("Set")) != -1 && func.BaseName() != _T("Set")) continue;
if (func.Find(_T("Get")) != -1) continue;
if (func.Find(_T("Init")) != -1) continue;
if (func.Find(_T("Close")) != -1) continue;
if (func.Find(_T("Malloc")) != -1) continue;
if (func.Find(_T("Free")) != -1) continue;
if (func.Found(_T("AlphaPremul"))) continue;
if (func.Found(_T("AddRotateShift"))) continue;
if (func.Found(_T("PutVal"))) continue;
if (func.Found(_T("UpdateTaps"))) continue;
if (func.Found(_T("DrawText"))) continue;
if (func.Found(_T("DV"))) continue;
POSITION dirPos = dirList.Find(func);
if (dirPos) {
dirList.RemoveAt(dirPos);
continue;
}
m_pOutstandList->AddTail(func);
RemoveAt(delPos);
}
return (int)m_pOutstandList->GetCount();
}
void CRecentFuncList::AddFunc(CFunc func)
{
POSITION rPos = GetHeadPosition();
while (rPos) {
POSITION pos = rPos;
if (GetNext(rPos) == func) RemoveAt(pos);
}
AddHead(func);
if (GetCount() > m_MaxSize) RemoveTail();
}
CFunc CRecentFuncList::GetFunc(int index)
{
POSITION rPos = GetHeadPosition();
for (int i = 1; rPos; i++) {
CFunc func = GetNext(rPos);
if (i == index) return func;
}
CFunc emptyFunc;
return emptyFunc;
}
static CVector* pMruVec = NULL;
static BOOL ValidMru(CString name)
{
CFunc func(name);
return func.Valid(pMruVec);
}
static BOOL InvalidMru(CString name)
{
return FALSE;
}
void CRecentFuncList::UpdateMenu(CCmdUI* pCmdUI, CVector* pVec, BOOL bEnable)
{
CMruMenu menu(8,_T("Recent Function"));
pMruVec = pVec;
if (GetCount() == 0) {
CFunc func = DEMO_APP->GetDirector()->GetProcess()->GetCurrentFunction();
if (!func.IsEmpty()) AddFunc(func);
}
menu.SetList(this);
menu.UpdateMenu(pCmdUI, bEnable ? ValidMru : InvalidMru);
}
/*
void CMruMenu::UpdateMenu(CCmdUI* pCmdUI)
{
CMenu* pMenu = pCmdUI->m_pMenu;
if (pMenu == NULL || GetSize() == 0) {
pCmdUI->Enable(FALSE);
pCmdUI->SetText(m_EmptyName);
return;
}
for (int iMRU = 0; iMRU < m_MenuSize; iMRU++)
pMenu->DeleteMenu(pCmdUI->m_nID + iMRU, MF_BYCOMMAND);
int nID = pCmdUI->m_nID;
POSITION pos = GetHeadPosition();
for (int i=0; i<mru.GetSize(); i++) {
pMenu->InsertMenu(pCmdUI->m_nIndex++, MF_STRING | MF_BYPOSITION,
nID, GetAt(i).name);
pMenu->EnableMenuItem(nID, MF_BYCOMMAND |
(GetAt(i).enable) ? MF_ENABLED : (MF_DISABLED | MF_GRAYED)));
nID++;
}
pCmdUI->m_nIndex--;
pCmdUI->m_nIndexMax = pMenu->GetMenuItemCount();
pCmdUI->m_bEnableChanged = TRUE; // all the added items are enabled
m_MenuSize = GetCount();
}
*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -