nsresult nsImageMap::SearchForAreas(nsIContent* aParent, PRBool& aFoundArea, PRBool& aFoundAnchor) { nsresult rv = NS_OK; PRUint32 i, n = aParent->GetChildCount(); // Look for <area> or <a> elements. We'll use whichever type we find first. for (i = 0; i < n; i++) { nsIContent *child = aParent->GetChildAt(i); if (child->IsHTML()) { // If we haven't determined that the map element contains an // <a> element yet, then look for <area>. if (!aFoundAnchor && child->Tag() == nsGkAtoms::area) { aFoundArea = PR_TRUE; rv = AddArea(child); NS_ENSURE_SUCCESS(rv, rv); // Continue to next child. This stops mContainsBlockContents from // getting set. It also makes us ignore children of <area>s which // is consistent with how we react to dynamic insertion of such // children. continue; } // If we haven't determined that the map element contains an // <area> element yet, then look for <a>. if (!aFoundArea && child->Tag() == nsGkAtoms::a) { aFoundAnchor = PR_TRUE; rv = AddArea(child); NS_ENSURE_SUCCESS(rv, rv); } } if (child->IsElement()) { mContainsBlockContents = PR_TRUE; rv = SearchForAreas(child, aFoundArea, aFoundAnchor); NS_ENSURE_SUCCESS(rv, rv); } } return NS_OK; }
BlockCacheBlock* BlockCache::AcquireBlock() { ScopedLock lock(&bcache_mutex); if ( !unused_block && !AddArea() ) return NULL; BlockCacheBlock* ret = unused_block; assert(ret); unused_block_count--; unused_block = unused_block->next_block; ret->prev_block = ret->next_block = NULL; if ( unused_block ) unused_block->prev_block = NULL; ret->information |= BCACHE_USED; LinkBlock(ret); blocks_used++; return ret; }
static bool ParseLine(AirspaceDatabase &airspace_database, int nLineType, unsigned &NumberOfAirspacePoints, unsigned &NumberOfAirspaceAreas, unsigned &NumberOfAirspaceCircles) { int nIndex; switch (nLineType) { case k_nLtAC: if (bFillMode) { if (!bWaiting) AddArea(airspace_database, &TempArea, NumberOfAirspaceAreas); TempArea.NumPoints = 0; TempArea.Type = OTHER; for (nIndex = 0; nIndex < k_nAreaCount; nIndex++) { if (StartsWith(&TempString[3], k_strAreaStart[nIndex])) { TempArea.Type = k_nAreaType[nIndex]; break; } } Rotation = +1; } else if (!bWaiting) // Don't count circles JG 10-Nov-2005 NumberOfAirspaceAreas++; Rotation = +1; bWaiting = false; break; case k_nLtAN: if (bFillMode) { TempString[NAME_SIZE] = '\0'; _tcscpy(TempArea.Name, &TempString[3]); } break; case k_nLtAL: if (bFillMode) ReadAltitude(&TempString[3], &TempArea.Base); break; case k_nLtAH: if (bFillMode) ReadAltitude(&TempString[3],&TempArea.Top); break; case k_nLtV: // Need to set these while in count mode, or DB/DA will crash if (StartsWith(&TempString[2], _T("X=")) || StartsWith(&TempString[2], _T("x="))) { if (ReadCoords(&TempString[4],&CenterX, &CenterY)) break; } else if (StartsWith(&TempString[2], _T("D=-")) || StartsWith(&TempString[2], _T("d=-"))) { Rotation = -1; break; } else if (StartsWith(&TempString[2], _T("D=+")) || StartsWith(&TempString[2], _T("d=+"))) { Rotation = +1; break; } else if (StartsWith(&TempString[2], _T("Z")) || StartsWith(&TempString[2], _T("z"))) { // ToDo Display Zool Level break; } else if (StartsWith(&TempString[2], _T("W")) || StartsWith(&TempString[2], _T("w"))) { // ToDo width of an airway break; } else if (StartsWith(&TempString[2], _T("T")) || StartsWith(&TempString[2], _T("t"))) { // ----- JMW THIS IS REQUIRED FOR LEGACY FILES break; } goto OnError; case k_nLtDP: /* if (bFillMode) { ReadCoords(&TempString[3],&TempPoint.Longitude , &TempPoint.Latitude ); AddPoint(&TempPoint); } else NumberOfAirspacePoints++; */ // if (bFillMode) if (!ReadCoords(&TempString[3],&TempPoint.Longitude , &TempPoint.Latitude)) goto OnError; AddPoint(airspace_database, &TempPoint, &TempArea.NumPoints, NumberOfAirspacePoints); // TempArea.NumPoints++; break; case k_nLtDB: CalculateArc(airspace_database, TempString, NumberOfAirspacePoints); break; case k_nLtDA: CalculateSector(airspace_database, TempString, NumberOfAirspacePoints); break; case k_nLtDC: if (bFillMode) { double Radius = _tcstod(&TempString[2], NULL); Radius = (Radius * NAUTICALMILESTOMETRES); AddAirspaceCircle(airspace_database, &TempArea, CenterX, CenterY, Radius, NumberOfAirspaceCircles); } else NumberOfAirspaceCircles++; bWaiting = true; break; default: break; } return(true); OnError: if (!bFillMode){ TCHAR sTmp[MAX_PATH]; _stprintf(sTmp, TEXT("%s: %d\r\n\"%s\"\r\n%s."), gettext(TEXT("Parse Error at Line")), LineCount, TempString, gettext(TEXT("Line skipped."))); if (MessageBoxX(sTmp, gettext(TEXT("Airspace")), MB_OKCANCEL) == IDCANCEL){ return(false); } } return(true); }
static void ReadAirspace(AirspaceDatabase &airspace_database, ZZIP_FILE *fp) { StartupStore(TEXT("ReadAirspace\n")); int Tock = 0; DWORD dwStep; DWORD dwPos; DWORD dwOldPos = 0L; int nLineType; unsigned NumberOfAirspacePointsPass[2] = { 0, 0 }; unsigned NumberOfAirspaceAreasPass[2] = { 0, 0 }; unsigned NumberOfAirspaceCirclesPass[2] = { 0, 0 }; LineCount = 0; airspace_database.SetQNH(QNH); XCSoarInterface::CreateProgressDialog(gettext(TEXT("Loading Airspace File..."))); // Need step size finer than default 10 XCSoarInterface::SetProgressStepSize(5); dwStep = zzip_file_size(fp) / 10L; TempArea.FirstPoint = airspace_database.NumberOfAirspacePoints; bFillMode = false; bWaiting = true; XCSoarInterface::StepProgressDialog(); while((nLineType = GetNextLine(fp, TempString)) >= 0) { Tock++; Tock %= 50; if (Tock == 0) { dwPos = zzip_tell(fp); if ((dwPos - dwOldPos) >= dwStep) { XCSoarInterface::StepProgressDialog(); dwOldPos = dwPos; } } if (!ParseLine(airspace_database, nLineType, NumberOfAirspacePointsPass[0], NumberOfAirspaceAreasPass[0], NumberOfAirspaceCirclesPass[0])) { CloseAirspace(airspace_database); return; } } // Process final area (if any). bFillMode is false. JG 10-Nov-2005 if (!bWaiting) NumberOfAirspaceAreasPass[0]++; // ???? // allocate new memory size_t screen_point_size = (airspace_database.NumberOfAirspacePoints + NumberOfAirspacePointsPass[0]) * sizeof(AirspaceScreenPoint[0]); POINT *new_points = AirspaceScreenPoint == NULL ? (POINT *)LocalAlloc(LMEM_FIXED, screen_point_size) : (POINT *)LocalReAlloc(AirspaceScreenPoint, LMEM_FIXED, screen_point_size); if (new_points != NULL) AirspaceScreenPoint = new_points; if ((screen_point_size > 0 && new_points == NULL) || !airspace_database.GrowPoints(NumberOfAirspacePointsPass[0]) || !airspace_database.GrowAreas(NumberOfAirspaceAreasPass[0]) || !airspace_database.GrowCircles(NumberOfAirspaceCirclesPass[0])) { // can't allocate memory, so delete everything airspace_database.Clear(); if (AirspaceScreenPoint != NULL) { LocalFree((HLOCAL)AirspaceScreenPoint); AirspaceScreenPoint = NULL; } return; } // ok, start the read TempArea.FirstPoint = airspace_database.NumberOfAirspacePoints; zzip_seek(fp, 0, SEEK_SET ); LineCount = -1; bFillMode = true; bWaiting = true; dwOldPos = 0L; XCSoarInterface::StepProgressDialog(); CenterY = CenterX = 0; Rotation = 1; while((nLineType = GetNextLine(fp, TempString)) >= 0) { Tock++; Tock %= 50; if (Tock == 0) { dwPos = zzip_tell(fp); if ((dwPos - dwOldPos) >= dwStep) { XCSoarInterface::StepProgressDialog(); dwOldPos = dwPos; } } ParseLine(airspace_database, nLineType, NumberOfAirspacePointsPass[1], NumberOfAirspaceAreasPass[1], NumberOfAirspaceCirclesPass[1]); } // Process final area (if any). bFillMode is true. JG 10-Nov-2005 if (!bWaiting) AddArea(airspace_database, &TempArea, NumberOfAirspaceAreasPass[1]); if (NumberOfAirspacePointsPass[0] != NumberOfAirspacePointsPass[1] || NumberOfAirspaceAreasPass[0] != NumberOfAirspaceAreasPass[1] || NumberOfAirspaceCirclesPass[0] != NumberOfAirspaceCirclesPass[1]){ if (MessageBoxX(gettext(TEXT("Internal Airspace Parser Error!\r\nPlease send this Airspacefile to Support")), gettext(TEXT("Airspace")), MB_OKCANCEL) == IDCANCEL) { } } #ifndef NDEBUG // only do this if debugging DumpAirspaceFile(airspace_database); #endif // if(AirspacePoint != NULL) LocalFree((HLOCAL)AirspacePoint); }
Areas(const RawHeader& header, std::size_t size) { AddArea(HEADER, 0); AddArea(PATTERNS, fromLE(header.PatternsOffset)); AddArea(END, size); }
void RowColumnManager::TabsChanged(Area* area) { RemoveArea(area); AddArea(area); }
/** * Function ClipAreaPolygon * Process an area that has been modified, by clipping its polygon against itself. * This may change the number and order of copper areas in the net. * @param aNewZonesList = a PICKED_ITEMS_LIST * where to store new areas pickers (useful in * undo commands) can be NULL * @param aCurrArea = the zone to process * @param bMessageBoxInt == true, shows message when clipping occurs. * @param bMessageBoxArc == true, shows message when clipping can't be done due to arcs. * @param bRetainArcs = true to handle arcs (not really used in KiCad) * @return: * -1 if arcs intersect other sides, so polygon can't be clipped * 0 if no intersecting sides * 1 if intersecting sides * Also sets areas->utility1 flags if areas are modified */ int BOARD::ClipAreaPolygon( PICKED_ITEMS_LIST * aNewZonesList, ZONE_CONTAINER* aCurrArea, bool bMessageBoxArc, bool bMessageBoxInt, bool bRetainArcs ) { CPolyLine* curr_polygon = aCurrArea->m_Poly; int test = TestAreaPolygon( aCurrArea ); // this sets utility2 flag if( test == -1 && !bRetainArcs ) test = 1; if( test == -1 ) { // arc intersections, don't clip unless bRetainArcs == false if( bMessageBoxArc && bDontShowSelfIntersectionArcsWarning == false ) { wxString str; str.Printf( wxT( "Area %08lX of net \"%s\" has arcs intersecting other sides.\n" ), aCurrArea->GetTimeStamp(), GetChars( aCurrArea->m_Netname ) ); str += wxT( "This may cause problems with other editing operations,\n" ); str += wxT( "such as adding cutouts. It can't be fixed automatically.\n" ); str += wxT( "Manual correction is recommended." ); wxMessageBox( str ); } return -1; // arcs intersect with other sides, error } // mark all areas as unmodified except this one for( unsigned ia = 0; ia < m_ZoneDescriptorList.size(); ia++ ) m_ZoneDescriptorList[ia]->utility = 0; aCurrArea->utility = 1; if( test == 1 ) { // non-arc intersections, clip the polygon if( bMessageBoxInt && bDontShowSelfIntersectionWarning == false ) { wxString str; str.Printf( wxT( "Area %08lX of net \"%s\" is self-intersecting and will be clipped.\n" ), aCurrArea->GetTimeStamp(), GetChars( aCurrArea->m_Netname ) ); str += wxT( "This may result in splitting the area.\n" ); str += wxT( "If the area is complex, this may take a few seconds." ); wxMessageBox( str ); // bDontShowSelfIntersectionWarning = dlg.bDontShowBoxState; } } //** TODO test for cutouts outside of area //** if( test == 1 ) { std::vector<CPolyLine*>* pa = new std::vector<CPolyLine*>; curr_polygon->UnHatch(); int n_poly = aCurrArea->m_Poly->NormalizeAreaOutlines( pa, bRetainArcs ); // i.e if clipping has created some polygons, we must add these new copper areas. if( n_poly > 1 ) { ZONE_CONTAINER* NewArea; for( int ip = 1; ip < n_poly; ip++ ) { // create new copper area and copy poly into it CPolyLine* new_p = (*pa)[ip - 1]; NewArea = AddArea( aNewZonesList, aCurrArea->GetNet(), aCurrArea->GetLayer(), wxPoint(0, 0), CPolyLine::NO_HATCH ); // remove the poly that was automatically created for the new area // and replace it with a poly from NormalizeAreaOutlines delete NewArea->m_Poly; NewArea->m_Poly = new_p; NewArea->m_Poly->Hatch(); NewArea->utility = 1; } } curr_polygon->Hatch(); delete pa; } return test; }