void CCoordinateLineDisplay::Draw(const TRect& aRect) const { TValueParts parts; SetCoordinate(iVal, parts); const TInt numLetters = sizeof("E 179+59+59+99+") - 1; const TInt pixelwidth = Rect().Width() - 16; const TInt step = pixelwidth / numLetters; CWindowGc& gc = SystemGc(); gc.SetClippingRect(aRect); gc.SetBrushColor(iBgClr); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); //gc.Clear(Rect()); //paint background color. gc.SetPenStyle(CGraphicsContext::ESolidPen); gc.SetPenColor(iTxtClr); #if defined NAV2_CLIENT_SERIES80 || defined NAV2_CLIENT_SERIES90_V1 TCknLogicalFont logicalfont(TCknLogicalFont::EViewLevel2ZoomDefaultFont); const class CFont* font = iEikonEnv->Font(logicalfont); #else const class CFont* font = CCoeEnv::Static()->NormalFont(); #endif gc.UseFont(font); TPoint offset(Rect().iTl.iX + (step/2), Rect().iTl.iY + 2); TInt baseline = font->AscentInPixels(); TRect paintRect(offset, TSize(step, Rect().Height() - 4)); baseline = baseline + ((paintRect.Height() - baseline)/2) - 1; for(TInt pos = 0; pos < iNewString.Length(); ++pos){ gc.DrawText(iNewString.Mid(pos,1), paintRect, baseline, CGraphicsContext::ECenter); paintRect.Move(step, 0); } }
/** * This method is used to determine the x/y range which completely covers the * area of interest specified by the lat/lon range. The latitude/longitude * range may be obtained from the labels. The purpose of this method is to * return the x/y range so it can be used to compute how large a map may need * to be. For example, how big a piece of paper is needed or how large of an * image needs to be created. The method may fail as indicated by its return * value. * * @param minX Minimum x projection coordinate which covers the latitude * longitude range specified in the labels. * * @param maxX Maximum x projection coordinate which covers the latitude * longitude range specified in the labels. * * @param minY Minimum y projection coordinate which covers the latitude * longitude range specified in the labels. * * @param maxY Maximum y projection coordinate which covers the latitude * longitude range specified in the labels. * * @return bool */ bool PointPerspective::XYRange(double &minX, double &maxX, double &minY, double &maxY) { double lat, lon; // Check the corners of the lat/lon range XYRangeCheck(m_minimumLatitude, m_minimumLongitude); XYRangeCheck(m_maximumLatitude, m_minimumLongitude); XYRangeCheck(m_minimumLatitude, m_maximumLongitude); XYRangeCheck(m_maximumLatitude, m_maximumLongitude); // Walk top and bottom edges for (lat = m_minimumLatitude; lat <= m_maximumLatitude; lat += 0.01) { lat = lat; lon = m_minimumLongitude; XYRangeCheck(lat, lon); lat = lat; lon = m_maximumLongitude; XYRangeCheck(lat, lon); } // Walk left and right edges for (lon = m_minimumLongitude; lon <= m_maximumLongitude; lon += 0.01) { lat = m_minimumLatitude; lon = lon; XYRangeCheck(lat, lon); lat = m_maximumLatitude; lon = lon; XYRangeCheck(lat, lon); } // Walk the limb for (double angle = 0.0; angle <= 360.0; angle += 0.01) { double x = m_equatorialRadius * cos(angle * PI / 180.0); double y = m_equatorialRadius * sin(angle * PI / 180.0); if (SetCoordinate(x, y) == 0) { if (m_latitude > m_maximumLatitude) continue; if (m_longitude > m_maximumLongitude) continue; if (m_latitude < m_minimumLatitude) continue; if (m_longitude < m_minimumLongitude) continue; XYRangeCheck(m_latitude, m_longitude); } } // Make sure everything is ordered if (m_minimumX >= m_maximumX) return false; if (m_minimumY >= m_maximumY) return false; // Return X/Y min/maxs minX = m_minimumX; maxX = m_maximumX; minY = m_minimumY; maxY = m_maximumY; return true; }
void CCoordinateLineDisplay::Format(TInt aVal) { class TValueParts parts; SetCoordinate(aVal, parts); HBufC* format = WFTextUtil::AllocLC(TOTAL_STRING); iNewString.Format(*format, iDirections[parts.iSign + 1], parts.iDeg, parts.iMin, parts.iSec, parts.iParts); CleanupStack::PopAndDestroy(format); }
// ----------------------------------------------------------------------------- // CPosLmNearestCriteria::ConstructL // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void CPosLmNearestCriteria::ConstructL( const TCoordinate& aCoordinate) { SetCoordinate(aCoordinate); }
void CMTDHistory::Load(FILE* fin) { if( fin == NULL ) { INVALID_ARGUMENT("stream is not open"); } // read MTD accumulator header ------------------ char mtd_id[4]; char ver_id[3]; int numofcoords = 0; int nr; // first line can contain either two or four records for version 0 char buffer[80]; if( fgets(buffer,80,fin) == NULL ) { RUNTIME_ERROR("unable to read the first line"); } nr = sscanf(buffer,"%3s %2s %d",mtd_id,ver_id,&numofcoords); if( nr != 3 ){ RUNTIME_ERROR("wrong header"); } mtd_id[3]='\0'; ver_id[2]='\0'; // check ID string if(strcmp(mtd_id,"MTD") != 0) { CSmallString error; error << "'MTD' magic word was not found in the first line (line: " << buffer << ")"; RUNTIME_ERROR(error); } if(strcmp(ver_id,"V3") != 0) { CSmallString error; error << "'illegal MTD history version (V3 expected) (line: " << buffer << ")"; RUNTIME_ERROR(error); } if(numofcoords <= 0) { CSmallString error; error << "number of coordinates has to be greater than zero, but " << numofcoords << " was found"; RUNTIME_ERROR(error); } SetNumberOfCoords(numofcoords); if( fin == NULL ) { INVALID_ARGUMENT("stream is not open"); } // read coordinate specification ---------------- for(unsigned int i=0; i < NCoords; i++) { unsigned int id = 0; char type[11]; char name[51]; double min_value = 0.0; double max_value = 0.0; int nbins = 0; int tr = 0; memset(type,0,11); memset(name,0,51); // read item tr = fscanf(fin,"%u %10s %lf %lf %d",&id,type,&min_value,&max_value,&nbins); if( tr != 5 ) { CSmallString error; error << "unable to read coordinate definition, id: " << i+1 << " (number of collums read: " << tr << ")"; RUNTIME_ERROR(error); } // some tests if(id != i+1) { CSmallString error; error << "coordinate id does not match, read: " << id << ", expected: " << i+1; RUNTIME_ERROR(error); } if(max_value <= min_value) { CSmallString error; error << "min value is not smaller than max value, id: " << id; RUNTIME_ERROR(error); } if(nbins <= 0) { CSmallString error; error << "number of bins has to be grater than zero, id: " << id; RUNTIME_ERROR(error); } tr = fscanf(fin,"%u %55s",&id,name); if( tr != 2 ) { CSmallString error; error << "unable to read coordinate definition, id: " << i+1 << " (number of collums read: " << tr << ")"; RUNTIME_ERROR(error); } // some tests if(id != i+1) { CSmallString error; error << "coordinate id does not match, read: " << id << ", expected: " << i+1; RUNTIME_ERROR(error); } // init coordinate SetCoordinate(i,name,type,min_value,max_value,nbins); } // now read records ----------------------------- unsigned int curr_position = 0; unsigned int position = 1; CMTDBuffer* p_buff = NULL; while(feof(fin) == 0) { int nr,level,time; if((p_buff == NULL) || (curr_position >= MaxBufferSize)) { // allocate new buffer p_buff = GetNewBuffer(MaxBufferSize); if(p_buff == NULL) { CSmallString error; error << "unable to allocate new buffer (pos: " << position << ")"; RUNTIME_ERROR(error); } curr_position = 0; } // read level and time nr = fscanf(fin,"%d %d",&level,&time); if(nr <= 0) break; // end of file if(nr != 2) { CSmallString error; error << "level and time were not successfully read (pos: " << position << ")"; RUNTIME_ERROR(error); } // now read height double height; nr = fscanf(fin,"%lf",&height); if(nr != 1) { CSmallString error; error << "unable to read height (pos: " << position << ")"; RUNTIME_ERROR(error); } p_buff->SetHeight(curr_position,height); for(unsigned int i=0; i < GetNumberOfCoords(); i++) { double value,width; nr = fscanf(fin,"%lf %lf",&value,&width); if(nr != 2) { CSmallString error; error << "unable to read value and width (pos: " << position << ")"; RUNTIME_ERROR(error); } // register value and width p_buff->SetValue(curr_position,i,value); p_buff->SetWidth(curr_position,i,width); } p_buff->IncNumberOfHills(); curr_position++; position++; } }