int CDiagramEntityContainer::Find( CDiagramEntity* testobj ) /* ============================================================ Function : CDiagramEntityContainer::Find Description : Finds the index of object testobj in the data array. Return : int - Index of the object or -1 if not found. Parameters : CDiagramEntity* testobj - Object to find. Usage : Internal function. ============================================================*/ { int index = -1; CDiagramEntity* obj; int count = 0; while( ( obj = GetAt( count ) ) ) { if( obj == testobj ) index = count; count++; } return index; }
int CDiagramEntityContainer::GetSelectCount() const { int count=0; for (int i = 0; i < GetSize(); i++) if (GetAt(i)->IsSelected()) count++; return count; }
void CDiagramEntityContainer::RemoveAt( int index ) /* ============================================================ Function : CDiagramEntityContainer::RemoveAt Description : Removes the object at index. Return : void Parameters : int index - The index of the object to remove. Usage : Call to remove a specific object. Memory is freed. ============================================================*/ { CDiagramEntity* obj = GetAt( index ); if( obj ) { if (obj == m_lastSelObj) m_lastSelObj = NULL; delete obj; m_objs.RemoveAt( index ); SetModified( TRUE ); } }
void CDiagramEntityContainer::Export( CStringArray& stra, UINT format ) const /* ============================================================ Function : CDiagramEntityContainer::Export Description : Exports all objects to format format. Return : void Parameters : CStringArray& stra - CStingArray that will be filled with data on return. UINT format - Format to save to. Usage : Call to export the contents of the container to a CStringArray. Export will - of course - have to be defined for the derived objects. ============================================================*/ { int max = GetSize(); for( int t = 0 ; t < max ; t++ ) { CDiagramEntity* obj = GetAt( t ); stra.Add( obj->Export( format ) ); } }
void Display::CComplexFillSymbol::Zoom(float rate) { for( int i = 0 ; i < GetSize() ; i++ ) { GetAt(i)->Zoom(rate); } }
bool CBoardCollectionArray::Add(DataStruct &board, CCEtoODBDoc &doc) { // look to see if this data will fit for (int i=0; i<GetCount(); i++) { if (GetAt(i)->Add(board, doc)) return true; } CBoardCollection *brdColl = new CBoardCollection(m_bUseAsRows); BlockStruct *block = doc.getBlockAt(board.getInsert()->getBlockNumber()); if (block == NULL) return false; CExtent ext = block->getExtent(); double toleranceDistance = 0.; if (m_bUseAsRows) toleranceDistance = ext.getYsize() * ((double)m_iTolerancePercent / 100.); else toleranceDistance = ext.getXsize() * ((double)m_iTolerancePercent / 100.); brdColl->SetTolerance(toleranceDistance); if (brdColl->Add(board, doc)) CTypedArrayContainer<CPtrArray, CBoardCollection*>::Add(brdColl); else return false; return true; }
/** Find the building center closest to the given point, if it is within * 'epsilon' distance. The building index, and distance from the given * point are returned by reference. * * \return True if a building was found. */ bool vtStructureArray::FindClosestBuildingCenter(const DPoint2 &point, double epsilon, int &building, double &closest) { if (IsEmpty()) return false; building = -1; DPoint2 loc; double dist; closest = 1E8; for (uint i = 0; i < GetSize(); i++) { vtStructure *str = GetAt(i); vtBuilding *bld = str->GetBuilding(); if (!bld) continue; bld->GetBaseLevelCenter(loc); dist = (loc - point).Length(); if (dist > epsilon) continue; if (dist < closest) { building = i; closest = dist; } } return (building != -1); }
void CXTPTaskPanelGroup::OnAnimate(int nStep) { if (nStep < 1) { m_rcGroupCurrent = m_rcGroupTarget; } else { MOVETO(m_rcGroupCurrent.top, m_rcGroupTarget.top, nStep); MOVETO(m_rcGroupCurrent.bottom, m_rcGroupTarget.bottom, nStep); } if (!IsDirty() && m_bExpanding) { m_bExpanding = FALSE; m_pPanel->NotifyOwner(XTP_TPN_GROUPEXPANDED, (LPARAM)this); } for (int i = 0; i < GetItemCount(); i++) { CXTPTaskPanelGroupItem* pItem = GetAt(i); pItem->OnAnimate(nStep); } }
/**--------------------------------------------------------------------------<BR> C2DBaseSet::SnapToGrid \brief SnapToGrid. <P>---------------------------------------------------------------------------*/ void C2DBaseSet::SnapToGrid(void) { for (unsigned int i = 0 ; i < size(); i++) { GetAt(i)->SnapToGrid(); } }
void* CFX_BaseSegmentedArray::Add() { if (m_DataSize % m_SegmentSize) { return GetAt(m_DataSize ++); } void* pSegment = FX_Alloc(FX_BYTE, m_UnitSize * m_SegmentSize); if (!pSegment) { return NULL; } if (m_pIndex == NULL) { m_pIndex = pSegment; m_DataSize ++; return pSegment; } if (m_IndexDepth == 0) { void** pIndex = (void**)FX_Alloc(void*, m_IndexSize); if (pIndex == NULL) { FX_Free(pSegment); return NULL; } pIndex[0] = m_pIndex; pIndex[1] = pSegment; m_pIndex = pIndex; m_DataSize ++; m_IndexDepth ++; return pSegment; }
bool CContainer::r_GetRefContainer( LPCTSTR & pszKey, CScriptObj * & pRef ) { ADDTOCALLSTACK("CContainer::r_GetRefContainer"); if ( !strnicmp(pszKey, "FIND", 4) ) // find* { pszKey += 4; if ( !strnicmp(pszKey, "ID", 2) ) // findid { pszKey += 2; SKIP_SEPARATORS(pszKey); pRef = ContentFind(g_Cfg.ResourceGetID(RES_ITEMDEF, pszKey)); SKIP_SEPARATORS(pszKey); return true; } else if ( !strnicmp(pszKey, "CONT", 4) ) // findcont { pszKey += 4; SKIP_SEPARATORS(pszKey); pRef = GetAt(Exp_GetSingle(pszKey)); SKIP_SEPARATORS(pszKey); return true; } else if ( !strnicmp(pszKey, "TYPE", 4) ) // findtype { pszKey += 4; SKIP_SEPARATORS(pszKey); pRef = ContentFind(g_Cfg.ResourceGetID(RES_TYPEDEF, pszKey)); SKIP_SEPARATORS(pszKey); return true; } } return false; }
void CCSClones::cleanup() { for (int i = 0; i < GetSize(); ++i) delete GetAt(i); RemoveAll(); }
BOOL CMediaFormats::IsUnPlayableFile(CString szFilename, bool bRestrict){ CPath fPath(szFilename); CString szThisExtention = fPath.GetExtension(); BOOL bDefaultRet = false; if(bRestrict) bDefaultRet = true; for(size_t i = 0; i < GetCount(); i++) { CMediaFormatCategory& mfc = GetAt(i); if( mfc.FindExt(szThisExtention) ){ CString szLabel = mfc.GetLabel(); if ( szLabel.Find(_T("Subtitle")) >= 0 || szLabel.Find(_T("字幕")) >= 0){ return TRUE; } if ( szLabel.Find(_T("Image file")) >= 0 || szLabel.Find(_T("图片")) >= 0){ return TRUE; } if ( szLabel.Find(_T("Real Script file")) >= 0 || szLabel.Find(_T("脚本")) >= 0){ return TRUE; } return FALSE; } } return bDefaultRet; }
// Calling this function with bEnable equals to true when // shuffle is already enabled will re-shuffle the tracks. void CPlaylist::SetShuffle(bool bEnable) { m_bShuffle = bEnable; if (bEnable && !IsEmpty()) { m_nShuffledListSize = GetCount(); CAtlArray<plsort_t> positions; positions.SetCount(m_nShuffledListSize + 1); srand((unsigned int)time(nullptr)); POSITION pos = GetHeadPosition(); for (size_t i = 0; pos; i++, GetNext(pos)) { positions[i].n = rand(); positions[i].pos = pos; } qsort(positions.GetData(), m_nShuffledListSize, sizeof(plsort_t), compare); positions[m_nShuffledListSize].pos = nullptr; // Termination m_posHeadShuffle = positions[0].pos; m_posTailShuffle = nullptr; for (size_t i = 0; i < m_nShuffledListSize; i++) { pos = positions[i].pos; CPlaylistItem& pli = GetAt(pos); pli.m_posPrevShuffle = m_posTailShuffle; pli.m_posNextShuffle = positions[i + 1].pos; m_posTailShuffle = pos; } } else { m_posHeadShuffle = m_posTailShuffle = nullptr; m_nShuffledListSize = 0; } }
void CPTRList::InsertBefore( int n,void *pData) { if ( n<0 ) { AddTail(pData); return; } if ( n==0 ) { AddHead(pData); return ; } GetAt(n); nCurrentBlk = -1; PTR_BLK *pNew = new PTR_BLK; pNew->pData = pData; pNew->pPrev = pCur->pPrev; pNew->pNext = pCur; pCur->pPrev->pNext = pNew; pCur->pPrev = pNew; nMax++; }
bool vtStructureArray::FindClosestLinearCorner(const DPoint2 &point, double epsilon, int &structure, int &corner, double &closest) { DPoint2 loc; double dist; uint i, j; structure = -1; corner = -1; closest = 1E8; for (i = 0; i < GetSize(); i++) { vtStructure *str = GetAt(i); vtFence *fen = str->GetFence(); if (!fen) continue; DLine2 &dl = fen->GetFencePoints(); for (j = 0; j < dl.GetSize(); j++) { dist = (dl.GetAt(j) - point).Length(); if (dist > epsilon) continue; if (dist < closest) { structure = i; corner = j; closest = dist; } } } return (structure != -1); }
CXTPTaskPanelGroupItem* CXTPTaskPanelGroup::HitTest(CPoint pt, CRect* lpRect) const { if (!IsExpanded()) return NULL; int nOffset = m_pPanel->GetScrollOffset() - m_nCaptionHeight - m_rcGroupCurrent.top + GetScrollOffsetPos(); pt.y += nOffset; for (int i = 0; i < GetItemCount(); i++) { CXTPTaskPanelGroupItem* pItem = GetAt(i); CRect rcItem = pItem->GetItemRect(); if (rcItem.PtInRect(pt) && pItem->IsVisible()) { if (lpRect) { rcItem.OffsetRect(0, -nOffset); *lpRect = rcItem; } return pItem; } } return NULL; }
void CPTRList::InsertAfter( int n,void *pData) { if ( n<0 ) { AddTail(pData); return ; } if ( n==GetCount()-1) { AddTail(pData); return; } GetAt(n); nCurrentBlk = -1; PTR_BLK *pNew = new PTR_BLK; pNew->pData = pData; pNew->pPrev = pCur; pNew->pNext = pCur->pNext; pCur->pNext->pPrev = pNew; pCur->pNext = pNew; nMax++; }
int CESBolanStack::FindKeyWordReverse(int KeyWord,int StartPos,int StopKeyWord) { if(StartPos>=(int)GetSize()) return -1; for(;StartPos>=0;StartPos--) { if(GetAt(StartPos)->Type==BOLAN_TYPE_KEYWORD) { if(StopKeyWord>0&&GetAt(StartPos)->Index==StopKeyWord) return -1; if(GetAt(StartPos)->Index==KeyWord) return StartPos; } } return -1; }
/**--------------------------------------------------------------------------<BR> C2DBaseSet::Project \brief Set projection. <P>---------------------------------------------------------------------------*/ void C2DBaseSet::Project(const C2DVector& Vector, CInterval& Interval) const { if (size() ==0) return; CInterval TempInt; GetAt(0)->Project( Vector, TempInt); for (unsigned int i = 1 ; i < size(); i++) { GetAt(i)->Project( Vector, TempInt); Interval.ExpandToInclude(TempInt); } }
/** Find the building corner closest to the given point, if it is within * 'epsilon' distance. The building index, corner index, and distance from * the given point are all returned by reference. * * \return True if a building was found. */ bool vtStructureArray::FindClosestBuildingCorner(const DPoint2 &point, double epsilon, int &building, int &corner, double &closest) { if (IsEmpty()) return false; building = -1; closest = 1E8; for (uint i = 0; i < GetSize(); i++) { vtStructure *str = GetAt(i); if (str->GetType() != ST_BUILDING) continue; vtBuilding *bld = str->GetBuilding(); const DPolygon2 &dl = bld->GetFootprint(0); int test_index; double test_distance; dl.NearestPoint(point, test_index, test_distance); if (test_distance < epsilon && test_distance < closest) { building = i; corner = test_index; closest = test_distance; } } return (building != -1); }
void vtStructureArray::Offset(const DPoint2 &delta) { uint npoints = GetSize(); if (!npoints) return; uint i, j; DPoint2 temp; for (i = 0; i < npoints; i++) { vtStructure *str = GetAt(i); vtBuilding *bld = str->GetBuilding(); if (bld) bld->Offset(delta); vtFence *fen = str->GetFence(); if (fen) { DLine2 line = fen->GetFencePoints(); for (j = 0; j < line.GetSize(); j++) line.GetAt(j) += delta; } vtStructInstance *inst = str->GetInstance(); if (inst) inst->Offset(delta); } }
/** * Find the building which is closest to the given point, if it is within * 'epsilon' distance. The structure index and distance are returned by * reference. * * \return True if a building was found. */ bool vtStructureArray::FindClosestBuilding(const DPoint2 &point, double epsilon, int &structure, double &closest) { structure = -1; closest = 1E8; DPoint2 loc; double dist; for (uint i = 0; i < GetSize(); i++) { vtStructure *str = GetAt(i); vtBuilding *bld = str->GetBuilding(); if (!bld) continue; dist = bld->GetDistanceToInterior(point); if (dist > epsilon) continue; if (dist < closest) { structure = i; closest = dist; } } return (structure != -1); }
int PyView::setSlice(int s, int e, const PWOSequence& lst) { int sz = GetSize(); if (s < 0) s += sz; if (e < 0) e += sz; if (e > sz) e = sz; int i = 0; for (; i < lst.len() && s < e; i++, s++) setItem(s, lst[i]); for (; i < lst.len(); i++, s++) { if (_base) Fail(PyExc_RuntimeError, "Can't insert in this view"); insertAt(s, lst[i]); } if (s < e) if (_base) while (s < e) { int ndx = _base->GetIndexOf(GetAt(s)); _base->RemoveAt(ndx, 1); --e; } else RemoveAt(s, e - s); return 0; }
engine_t CMediaFormats::GetEngine(CString path) { path.Trim().MakeLower(); if(!m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0) return m_iRtspHandler; CString ext = CPath(path).GetExtension(); ext.MakeLower(); if(!ext.IsEmpty()) { if(path.Find(_T("rtsp://")) == 0) { if(ext == _T(".ram") || ext == _T(".rm") || ext == _T(".ra")) return RealMedia; if(ext == _T(".qt") || ext == _T(".mov")) return QuickTime; }else if(ext == _T(".ram")){ return RealMedia; } for(size_t i = 0; i < GetCount(); i++) { CMediaFormatCategory& mfc = GetAt(i); if(mfc.FindExt(ext)) return mfc.GetEngineType(); } } if(m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0) return m_iRtspHandler; return DirectShow; }
bool vtStructureArray::WriteXML(const char* filename, bool bGZip) const { VTLOG("WriteXML(%s)\n", filename); // Avoid trouble with '.' and ',' in Europe LocaleWrap normal_numbers(LC_NUMERIC, "C"); GZOutput out(bGZip); if (!gfopen(out, filename)) { throw xh_io_exception("Could not open output file", xh_location(filename), "XML Writer"); } gfprintf(out, "<?xml version=\"1.0\"?>\n"); gfprintf(out, "\n"); gfprintf(out, "<StructureCollection xmlns=\"http://www.openplans.net\"\n" "\t\t\t\t\t xmlns:gml=\"http://www.opengis.net/gml\"\n" "\t\t\t\t\t xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" "\t\t\t\t\t xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" "\t\t\t\t\t xsi:schemaLocation=\"http://www.openplans.net/buildings.xsd\">\n"); gfprintf(out, "\n"); // Write the extents (required by gml:StructureCollection) DRECT ext; GetExtents(ext); gfprintf(out, "\t<gml:boundedBy>\n"); gfprintf(out, "\t\t<gml:Box>\n"); gfprintf(out, "\t\t\t<gml:coordinates>"); gfprintf(out, "%.9lf,%.9lf %.9lf,%.9lf", ext.left, ext.bottom, ext.right, ext.top); gfprintf(out, "</gml:coordinates>\n"); gfprintf(out, "\t\t</gml:Box>\n"); gfprintf(out, "\t</gml:boundedBy>\n"); gfprintf(out, "\n"); // Write projection char *wkt; OGRErr err = m_proj.exportToWkt(&wkt); if (err != OGRERR_NONE) { throw xh_io_exception("Couldn't write CRS to file", xh_location(filename), "XML Writer"); } gfprintf(out, "\t<SRS>%s</SRS>\n", wkt); gfprintf(out, "\n"); OGRFree(wkt); bool bDegrees = (m_proj.IsGeographic() == 1); for (uint i = 0; i < GetSize(); i++) { vtStructure *str = GetAt(i); str->WriteXML(out, bDegrees); } gfprintf(out, "</StructureCollection>\n"); gfclose(out); return true; }
void CZipExtraField::Remove(WORD headerID) { for (int i = GetCount() - 1; i >= 0; i--) { if (headerID == GetAt(i)->GetHeaderID()) RemoveAt(i); } }
void vtRouteMap::BuildGeometry(vtHeightField3d *pHeightField) { int routes = GetSize(); for (int i = 0; i < routes; i++) { GetAt(i)->BuildGeometry(pHeightField); } }
void CZipExtraField::Write(char* buffer)const { int offset = 0; for (int i = 0; i < GetCount(); i++) { offset += GetAt(i)->Write(buffer + offset); } }
/**--------------------------------------------------------------------------<BR> C2DLineBaseSet::AddIfCommonEnd \brief Adds the points of another to this if they have a common end which is either the first or last point. Returns true if there was a match. <P>---------------------------------------------------------------------------*/ bool C2DLineBaseSet::AddIfCommonEnd(C2DLineBaseSet& Other) { assert(!IsClosed()); assert(!Other.IsClosed()); int nThisCount = size() ; if (nThisCount < 1) return false; int nOtherCount = Other.size(); if (nOtherCount < 1) return false; if ( GetAt(0)->GetPointFrom() == Other.GetAt(0)->GetPointFrom()) { ReverseDirection(); *this << Other; return true; } else if( GetAt(0)->GetPointFrom() == Other.GetAt(nOtherCount - 1)->GetPointTo() ) { ReverseDirection(); Other.ReverseDirection(); *this << Other; return true; } else if (GetAt(nThisCount - 1)->GetPointTo() == Other.GetAt(0)->GetPointFrom()) { *this << Other; return true; } else if (GetAt(nThisCount - 1)->GetPointTo() == Other.GetAt(nOtherCount - 1)->GetPointTo() ) { Other.ReverseDirection(); *this << Other; return true; } return false; }