static bool ContainsDirectory(nsIAbDirectory *parent, nsIAbDirectory *directory)
{
  // If parent is a maillist, 'addressLists' contains AbCards.
  bool bIsMailList = false;
  nsresult rv = parent->GetIsMailList(&bIsMailList);
  NS_ENSURE_SUCCESS(rv, false);

  if (bIsMailList)
    return false;

  nsCOMPtr<nsIMutableArray> pAddressLists;
  parent->GetAddressLists(getter_AddRefs(pAddressLists));
  if (pAddressLists)
  {
    uint32_t total;
    rv = pAddressLists->GetLength(&total);
    for (uint32_t i = 0; i < total; ++i)
    {
      nsCOMPtr<nsIAbDirectory> pList(do_QueryElementAt(pAddressLists, i, &rv));

      if (directory == pList)
          return true;
    }
  }

  return false;
}
示例#2
0
HRESULT CLibraryWnd::GetGenericView(IGenericView** ppView)
{
	if ( m_wndFrame.m_hWnd == NULL ) return S_FALSE;
	CLibraryListPtr pList( m_wndFrame.GetViewSelection() );
	*ppView = (IGenericView*)pList->GetInterface( IID_IGenericView, TRUE );
	return S_OK;
}
static PRBool ContainsDirectory(nsIAbDirectory *parent, nsIAbDirectory *directory)
{
  // If parent is a maillist, 'addressLists' contains AbCards.
  PRBool bIsMailList = PR_FALSE;
  nsresult rv = parent->GetIsMailList(&bIsMailList);
  NS_ENSURE_SUCCESS(rv, rv);

  if (bIsMailList)
    return PR_FALSE;

  nsCOMPtr<nsIMutableArray> pAddressLists;
  parent->GetAddressLists(getter_AddRefs(pAddressLists));
  if (pAddressLists)
  {
    PRUint32 total;
    rv = pAddressLists->GetLength(&total);
    for (PRUint32 i = 0; i < total; ++i)
    {
      nsCOMPtr<nsIAbDirectory> pList(do_QueryElementAt(pAddressLists, i, &rv));

      if (directory == pList)
          return PR_TRUE;
    }
  }

  return PR_FALSE;
}
示例#4
0
  uint32_t CDeviceDriver::readGlobal(CVMUSB& ctlr) 
  {
    unique_ptr<CVMUSBReadoutList> pList(ctlr.createReadoutList());
    addReadGlobal(*pList);

    return executeList<uint32_t>(ctlr,*pList);
  }
示例#5
0
void desktopSelection::slotMetaViewPkgs()
{
        QStringList packageList;
        QTreeWidgetItemIterator it(treeWidgetDesktopPackages);
        while (*it) {
          for (int z=0; z < listDeskPkgs.count(); ++z) {
            if ( (*it)->isSelected() && (*it)->text(0) == listDeskPkgs.at(z).at(0) ) {
        
                QFile pList(listDeskPkgs.at(z).at(6));
                if ( ! pList.exists() )
                  return;
                
                if ( ! pList.open(QIODevice::ReadOnly | QIODevice::Text))
                  return;
              
                while ( !pList.atEnd() )
                  packageList << pList.readLine().simplified();
           
                pList.close();
                packageList.sort();
 
                dIB = new dialogInfoBox();
                dIB->programInit(tr("Package Listing for:") + " " + (*it)->text(0));
                dIB->setInfoText(packageList.join("\n"));
                dIB->show();
            }
          }
         ++it;
        }
}
void CLibraryFileView::OnLibraryDelete()
{
	CSingleLock pTransfersLock( &Transfers.m_pSection, TRUE );	// Can clear uploads and downloads
	CSingleLock pLibraryLock( &Library.m_pSection, TRUE );

	CLibraryListPtr pList( new CLibraryList() );

	POSITION posSel = StartSelectedFileLoop();
	while ( CLibraryFile* pFile = GetNextSelectedFile( posSel, FALSE, ! m_bGhostFolder ) )
	{
		pList->AddTail( pFile );
	}

	while ( ! pList->IsEmpty() )
	{
		CLibraryFile* pFile = Library.LookupFile( pList->GetHead(), FALSE, ! m_bGhostFolder );
		if ( pFile == NULL )
		{
			pList->RemoveHead();	// Remove item from list to avoid endless loop
			continue;
		}

		if ( m_bGhostFolder )
		{
			for ( INT_PTR nProcess = pList->GetCount() ; nProcess > 0 && pList->GetCount() > 0 ; nProcess-- )
			{
				if ( ( pFile = Library.LookupFile( pList->RemoveHead() ) ) != NULL )
					pFile->Delete( TRUE );
			}
		}
		else
		{
			CDeleteFileDlg dlg( this );
			dlg.m_sName	= pFile->m_sName;
			dlg.m_sComments = pFile->m_sComments;
			dlg.m_nRateValue = pFile->m_nRating;
			dlg.m_bAll	= pList->GetCount() > 1;

			pLibraryLock.Unlock();
			pTransfersLock.Unlock();

			if ( dlg.DoModal() != IDOK ) break;

			pTransfersLock.Lock();
			pLibraryLock.Lock();

			for ( INT_PTR nProcess = dlg.m_bAll ? pList->GetCount() : 1 ; nProcess > 0 && pList->GetCount() > 0 ; nProcess-- )
			{
				if ( ( pFile = Library.LookupFile( pList->RemoveHead(), FALSE, TRUE ) ) != NULL )
				{
					dlg.Apply( pFile );
					pFile->Delete();
				}
			}
		}

		Library.Update( true );
	}
}
XMLConfiguration::config_list_ptr_type
XMLConfiguration::getConfigurationElements()
{
    XMLConfiguration::config_list_ptr_type pList(new XMLConfiguration::config_list_ptr_type());

    config_collection_type::iterator iter;
    for(iter = m_config.begin(); iter != m_config.end(); ++iter)
    {
        pList->push_back(dynamic_cast<I_ConfigurationElement::const_ptr_type>(iter->second));
    }

    return pList;
}
示例#8
0
void CLibraryMetaPanel::OnLButtonUp(UINT nFlags, CPoint point)
{
	point.y += GetScrollPos( SB_VERT );

	if ( m_nSelected > 0 && m_rcFolder.PtInRect( point ) )
	{
		CQuickLock oLock( Library.m_pSection );

		if ( CLibraryFolder* pFolder = LibraryFolders.GetFolder( m_sFolder ) )
		{
			if ( Settings.Library.ShowVirtual )
			{
				CLibraryFrame* pFrame = (CLibraryFrame*)GetOwner();
				ASSERT_KINDOF(CLibraryFrame, pFrame );
				pFrame->Display( pFolder );
			}
			else if ( LibraryFolders.CheckFolder( pFolder, TRUE ) )
			{
				ShellExecute( AfxGetMainWnd()->GetSafeHwnd(), NULL,
					m_sFolder, NULL, NULL, SW_SHOWNORMAL );
			}
		}
	}
	else if ( m_nSelected > 0 && m_rcRating.PtInRect( point ) )
	{
		CLibraryListPtr pList( GetViewSelection() );

		if ( pList && pList->GetCount() > 0 )
		{
			CFilePropertiesSheet dlg;
			dlg.Add( pList );
			dlg.DoModal( 2 );
		}
	}
	else if ( CMetaItem* pItem = m_pMetadata->HitTest( point, TRUE ) )
	{
		CQuickLock oLock( Library.m_pSection );

		if ( CAlbumFolder* pFolder = pItem->GetLinkTarget() )
		{
			CLibraryFrame* pFrame = (CLibraryFrame*)GetOwner();
			ASSERT_KINDOF(CLibraryFrame, pFrame );
			pFrame->Display( pFolder );
		}
	}

	CPanelCtrl::OnLButtonUp( nFlags, point );
}
示例#9
0
void CFileSharingPage::OnOK()
{
	UpdateData();

	CLibraryListPtr pList( GetList() );
	if ( pList )
	{
		CQuickLock oLock( Library.m_pSection );

		for ( POSITION pos = pList->GetHeadPosition(); pos; )
		{
			if ( CLibraryFile* pFile = pList->GetNextFile( pos ) )
			{
				pFile->SetShared( ( m_bShare != FALSE ), ( m_bOverride != FALSE ) );
				pFile->m_sShareTags = m_sTags;
			}
		}
	}

	CFilePropertiesPage::OnOK();
}
示例#10
0
static PT_Tree pTreeWithSymbol(PT_Tree tree, int *i, PT_Symbol sym, SDF_Symbol ssym)
{
  if (PT_isSymbolSort(sym)) {
    return pTree(tree, i);
  }
  else if (PT_isSymbolLit(sym)) {
    return tree;
  }
  else if (PT_isSymbolIterStar(sym) || PT_isSymbolIterPlus(sym)) {
    return pList(tree, i, ssym);
  }
  else if (PT_isSymbolIterStarSep(sym) || PT_isSymbolIterPlusSep(sym)) {
    return pSepList(tree, i, ssym);
  }

  /* the rest is handled by doing nothing */
  if (PT_hasTreeArgs(tree)) {
    return PT_setTreeArgs(tree, pArgs(PT_getTreeArgs(tree), i));
  }
  else {
    return tree;
  }
}
示例#11
0
    cv::Mat Deformation::DeformByMovingLeastSquares(const cv::Mat& inputImg, 
            const std::vector<int>& originIndex, const std::vector<int>& targetIndex)
    {
        int imgW = inputImg.cols;
        int imgH = inputImg.rows;
        cv::Size imgSize(imgW, imgH);
        cv::Mat resImg(imgSize, CV_8UC3);
        int markNum = originIndex.size() / 2;
        std::vector<double> wList(markNum);
        std::vector<MagicMath::Vector2> pHatList(markNum);
        std::vector<MagicMath::Vector2> qHatList(markNum);
        MagicMath::Vector2 pStar, qStar;
        std::vector<MagicMath::Vector2> pList(markNum);
        for (int mid = 0; mid < markNum; mid++)
        {
            pList.at(mid) = MagicMath::Vector2(originIndex.at(mid * 2), originIndex.at(mid * 2 + 1));
        }
        std::vector<MagicMath::Vector2> qList(markNum);
        for (int mid = 0; mid < markNum; mid++)
        {
            qList.at(mid) = MagicMath::Vector2(targetIndex.at(mid * 2), targetIndex.at(mid * 2 + 1));
        }
        std::vector<std::vector<double> > aMatList(markNum);
        std::vector<bool> visitFlag(imgW * imgH, 0);

        for (int hid = 0; hid < imgH; hid++)
        {
            for (int wid = 0; wid < imgW; wid++)
            {
                MagicMath::Vector2 pos(wid, hid);
                //calculate w
                bool isMarkVertex = false;
                int markedIndex = -1;
                double wSum = 0;
                for (int mid = 0; mid < markNum; mid++)
                {
                    //double dTemp = (pos - pList.at(mid)).LengthSquared(); //variable
                    double dTemp = (pos - pList.at(mid)).Length();
                    //dTemp = pow(dTemp, 1.25);
                    if (dTemp < 1.0e-15)
                    {
                        isMarkVertex = true;
                        markedIndex = mid;
                        break;
                    }
                    dTemp = pow(dTemp, 1.25);
                    wList.at(mid) = 1.0 / dTemp;
                    wSum += wList.at(mid);
                }
                //
                if (isMarkVertex)
                {
                    const unsigned char* pPixel = inputImg.ptr(hid, wid);
                    int targetH = targetIndex.at(2 * markedIndex + 1);
                    int targetW = targetIndex.at(2 * markedIndex);
                    unsigned char* pResPixel = resImg.ptr(targetH, targetW);
                    pResPixel[0] = pPixel[0];
                    pResPixel[1] = pPixel[1];
                    pResPixel[2] = pPixel[2];
                    visitFlag.at(targetH * imgW + targetW) = 1;
                }
                else
                {
                    //Calculate pStar qStar
                    pStar = MagicMath::Vector2(0.0, 0.0);
                    qStar = MagicMath::Vector2(0.0, 0.0);
                    for (int mid = 0; mid < markNum; mid++)
                    {
                        pStar += (pList.at(mid) * wList.at(mid));
                        qStar += (qList.at(mid) * wList.at(mid));
                    }
                    pStar /= wSum;
                    qStar /= wSum;

                    //Calculate pHat qHat
                    for (int mid = 0; mid < markNum; mid++)
                    {
                        pHatList.at(mid) = pList.at(mid) - pStar;
                        qHatList.at(mid) = qList.at(mid) - qStar;
                    }
                    
                    //Calculate A
                    MagicMath::Vector2 col0 = pos - pStar;
                    MagicMath::Vector2 col1(col0[1], -col0[0]);
                    for (int mid = 0; mid < markNum; mid++)
                    {
                        std::vector<double> aMat(4);
                        MagicMath::Vector2 row1(pHatList.at(mid)[1], -pHatList.at(mid)[0]);
                        aMat.at(0) = pHatList.at(mid) * col0 * wList.at(mid);
                        aMat.at(1) = pHatList.at(mid) * col1 * wList.at(mid);
                        aMat.at(2) = row1 * col0 * wList.at(mid);
                        aMat.at(3) = row1 * col1 * wList.at(mid);
                        aMatList.at(mid) = aMat;
                    }

                    //Calculate fr(v)
                    MagicMath::Vector2 fVec(0, 0);
                    for (int mid = 0; mid < markNum; mid++)
                    {
                        fVec[0] += (qHatList.at(mid)[0] * aMatList.at(mid).at(0) + qHatList.at(mid)[1] * aMatList.at(mid).at(2));
                        fVec[1] += (qHatList.at(mid)[0] * aMatList.at(mid).at(1) + qHatList.at(mid)[1] * aMatList.at(mid).at(3));
                    }

                    //Calculate target position
                    fVec.Normalise();
                    MagicMath::Vector2 targetPos = fVec * ((pos - pStar).Length()) + qStar;
                    int targetW = targetPos[0];
                    int targetH = targetPos[1];
                    if (targetH >= 0 && targetH < imgH && targetW >= 0 && targetW < imgW)
                    {
                        const unsigned char* pPixel = inputImg.ptr(hid, wid);
                        unsigned char* pResPixel = resImg.ptr(targetH, targetW);
                        pResPixel[0] = pPixel[0];
                        pResPixel[1] = pPixel[1];
                        pResPixel[2] = pPixel[2];
                        visitFlag.at(targetH * imgW + targetW) = 1;
                    }
                }
            }
        }

        std::vector<int> unVisitVecH;
        std::vector<int> unVisitVecW;
        for (int hid = 0; hid < imgH; hid++)
        {
            int baseIndex = hid * imgW;
            for (int wid = 0; wid < imgW; wid++)
            {
                if (!visitFlag.at(baseIndex + wid))
                {
                    unVisitVecH.push_back(hid);
                    unVisitVecW.push_back(wid);
                }
            }
        }
        int minAcceptSize = 4;
        int fillTime = 1;
        while (unVisitVecH.size() > 0)
        {
            DebugLog << "unVisit number: " << unVisitVecH.size() << std::endl;
            std::vector<int> unVisitVecHCopy = unVisitVecH;
            std::vector<int> unVisitVecWCopy = unVisitVecW;
            unVisitVecH.clear();
            unVisitVecW.clear();
            int unVisitSize = unVisitVecHCopy.size();
            for (int uid = 0; uid < unVisitSize; uid++)
            {
                MagicMath::Vector3 avgColor(0, 0, 0);
                int hid = unVisitVecHCopy.at(uid);
                int wid = unVisitVecWCopy.at(uid);
                int avgSize = 0;
                if ((hid - 1) >= 0 && visitFlag.at((hid - 1) * imgW + wid))
                {
                    unsigned char* pPixel = resImg.ptr(hid - 1, wid);
                    avgColor[0] += pPixel[0];
                    avgColor[1] += pPixel[1];
                    avgColor[2] += pPixel[2];
                    avgSize++;
                }
                if ((hid + 1) < imgH && visitFlag.at((hid + 1) * imgW + wid))
                {
                    unsigned char* pPixel = resImg.ptr(hid + 1, wid);
                    avgColor[0] += pPixel[0];
                    avgColor[1] += pPixel[1];
                    avgColor[2] += pPixel[2];
                    avgSize++;
                }
                if ((wid - 1) >= 0 && visitFlag.at(hid * imgW + wid - 1))
                {
                    unsigned char* pPixel = resImg.ptr(hid, wid - 1);
                    avgColor[0] += pPixel[0];
                    avgColor[1] += pPixel[1];
                    avgColor[2] += pPixel[2];
                    avgSize++;
                }
                if ((wid + 1) < imgW && visitFlag.at(hid * imgW + wid + 1))
                {
                    unsigned char* pPixel = resImg.ptr(hid, wid + 1);
                    avgColor[0] += pPixel[0];
                    avgColor[1] += pPixel[1];
                    avgColor[2] += pPixel[2];
                    avgSize++;
                }
                if (avgSize >= minAcceptSize)
                {
                    visitFlag.at(hid * imgW + wid) = 1;
                    avgColor /= avgSize;
                    unsigned char* pFillPixel = resImg.ptr(hid, wid);
                    pFillPixel[0] = avgColor[0];
                    pFillPixel[1] = avgColor[1];
                    pFillPixel[2] = avgColor[2];
                }
                else
                {
                    unVisitVecH.push_back(hid);
                    unVisitVecW.push_back(wid);
                }
            }
            if (fillTime == 4)
            {
                minAcceptSize--;
            }
            else if (fillTime == 6)
            {
                minAcceptSize--;
            }
            else if (fillTime == 8)
            {
                minAcceptSize--;
            }
            fillTime++;
        }
        //fill hole
        /*for (int hid = 0; hid < imgH; hid++)
        {
            int baseIndex = hid * imgW;
            for (int wid = 0; wid < imgW; wid++)
            {
                if (!visitFlag.at(baseIndex + wid))
                {
                    double wSum = 0;
                    MagicMath::Vector3 avgColor(0, 0, 0);
                    for (int wRight = wid + 1; wRight < imgW; wRight++)
                    {
                        if (visitFlag.at(baseIndex + wRight))
                        {
                            double wTemp = 1.0 / (wRight - wid);
                            wSum += wTemp;
                            unsigned char* pPixel = resImg.ptr(hid, wRight);
                            avgColor[0] += wTemp * pPixel[0];
                            avgColor[1] += wTemp * pPixel[1];
                            avgColor[2] += wTemp * pPixel[2];
                            break;
                        }
                    }
                    for (int wLeft = wid - 1; wLeft >= 0; wLeft--)
                    {
                        if (visitFlag.at(baseIndex + wLeft))
                        {
                            double wTemp = 1.0 / (wid - wLeft);
                            wSum += wTemp;
                            unsigned char* pPixel = resImg.ptr(hid, wLeft);
                            avgColor[0] += wTemp * pPixel[0];
                            avgColor[1] += wTemp * pPixel[1];
                            avgColor[2] += wTemp * pPixel[2];
                            break;
                        }
                    }
                    for (int hUp = hid - 1; hUp >= 0; hUp--)
                    {
                        if (visitFlag.at(hUp * imgW + wid))
                        {
                            double wTemp = 1.0 / (hid - hUp);
                            unsigned char* pPixel = resImg.ptr(hUp, wid);
                            wSum += wTemp;
                            avgColor[0] += wTemp * pPixel[0];
                            avgColor[1] += wTemp * pPixel[1];
                            avgColor[2] += wTemp * pPixel[2];
                            break;
                        }
                    }
                    for (int hDown = hid + 1; hDown < imgH; hDown++)
                    {
                        if (visitFlag.at(hDown * imgW + wid))
                        {
                            double wTemp = 1.0 / (hDown - hid);
                            unsigned char* pPixel = resImg.ptr(hDown, wid);
                            wSum += wTemp;
                            avgColor[0] += wTemp * pPixel[0];
                            avgColor[1] += wTemp * pPixel[1];
                            avgColor[2] += wTemp * pPixel[2];
                            break;
                        }
                    }
                    if (wSum > 1.0e-15)
                    {
                        avgColor /= wSum;
                    }
                    unsigned char* pFillPixel = resImg.ptr(hid, wid);
                    pFillPixel[0] = avgColor[0];
                    pFillPixel[1] = avgColor[1];
                    pFillPixel[2] = avgColor[2];
                }
            }
        }*/
        return resImg;
    }
示例#12
0
BOOL CFileSharingPage::OnInitDialog()
{
	CFilePropertiesPage::OnInitDialog();

	m_wndTags.AddString( L"" );

	{
		CQuickLock oLock( UploadQueues.m_pSection );

		CList< CString > pAdded;

		for ( POSITION pos = UploadQueues.GetIterator(); pos; )
		{
			CUploadQueue* pQueue = UploadQueues.GetNext( pos );

			if ( ! pQueue->m_sShareTag.IsEmpty() )
			{
				if ( pAdded.Find( pQueue->m_sShareTag ) == NULL )
				{
					pAdded.AddTail( pQueue->m_sShareTag );
					m_wndTags.AddString( pQueue->m_sShareTag );
				}
			}
		}

		if ( pAdded.IsEmpty() )
		{
			m_wndTags.AddString( L"Release" );
			m_wndTags.AddString( L"Popular" );
		}
	}

	{
		CQuickLock oLock( Library.m_pSection );

		if ( CLibraryFile* pSingleFile = GetFile() )
		{
			m_bOverride	= pSingleFile->IsSharedOverride();
			m_bShare	= pSingleFile->IsShared();
			m_sTags		= pSingleFile->m_sShareTags;
		}
		else
		{
			CLibraryListPtr pList( GetList() );
			if ( pList )
			{
				for ( POSITION pos = pList->GetHeadPosition(); pos; )
				{
					if ( CLibraryFile* pFile = pList->GetNextFile( pos ) )
					{
						m_bOverride	= pFile->IsSharedOverride();
						m_bShare	= pFile->IsShared();
						m_sTags		= pFile->m_sShareTags;
					}
				}
			}
		}
	}

	UpdateData( FALSE );
	m_wndShare.EnableWindow( m_bOverride );

	return TRUE;
}