void HistoryListItem::elideTextWithWidth(int w) { if (url_label_ && title_label_) { QFont font(url_label_->font()); font.setPixelSize(GetWindowFontSize(DKLabelIndex)); QFontMetrics fm(font); url_label_->setText(fm.elidedText(url_label_->text(), Qt::ElideRight, w)); title_label_->setText(fm.elidedText(title_label_->text(), Qt::ElideRight, w)); } }
void WebBrowserLauncher::ShowBlockUITip() { CDisplay::CacheDisabler forceDraw; if(m_msgBoxTip) { SafeDeletePointer(m_msgBoxTip); } m_msgBoxTip = new UIMessageBox(GUISystem::GetInstance()->GetTopFullScreenContainer(), StringManager::GetStringById(WEBBROSER_START), MB_WITHOUTBTN); m_msgBoxTip->SetTipText(StringManager::GetStringById(WEBBROSER_START_TIP)); m_msgBoxTip->SetEnableHookTouch(true); UIText* displayText = m_msgBoxTip->GetTextDisplay(); displayText->SetAlign(ALIGN_CENTER); displayText->SetFontSize(GetWindowFontSize(FontSize24Index)); UIText* tipText = m_msgBoxTip->GetTextTip(); tipText->SetFontSize(GetWindowFontSize(FontSize16Index)); tipText->SetAlign(ALIGN_CENTER); m_msgBoxTip->Popup(); CDisplay* display = CDisplay::GetDisplay(); display->ForceDraw(PAINT_FLAG_FULL); }
void HistoryListItem::paintEvent(QPaintEvent* event) { if (!date_.isNull()) { qDebug() << "HistoryPage::paintEvent\t" << date_ << "\thasFocus: " << hasFocus(); QPainter painter(this); QFont textFont = font(); textFont.setPixelSize(GetWindowFontSize(HistoryDateIndex)); setFont(textFont); painter.drawText(rect(), Qt::AlignLeft | Qt::AlignVCenter, date_); if (line_pixel_ > 0) { painter.drawLine(0, 0, width(), line_pixel_ - 1); } } else { QWidget::paintEvent(event); } }
void CLapPainter::DrawGeneralGraph(const LAPSUPPLIEROPTIONS& sfLapOpts, bool fHighlightXAxis) { vector<CExtendedLap*> lstLaps = m_pLapSupplier->GetLapsToShow(); DATA_CHANNEL eX; eX = DATA_CHANNEL_DISTANCE; set<DATA_CHANNEL> setY; map<DATA_CHANNEL,float> mapMinY; map<DATA_CHANNEL,float> mapMaxY; float dMaxX = -1e30; float dMinX = 1e30; float dCenterOvalX = 0; float dCenterOvalY = 0; { // figuring out bounds and getting matrices all set up // First lets load up all of the data into an array and determine its size for(int x = 0;x < lstLaps.size(); x++) { CExtendedLap* pLap = lstLaps[x]; DATA_CHANNEL eDataX = m_pLapSupplier->GetXChannel(); const IDataChannel* pDataX = pLap->GetChannel(eDataX); if(!pDataX || !pDataX->IsValid() || pDataX->GetData().size() <= 0) continue; vector<DATA_CHANNEL> lstDataY = m_pLapSupplier->GetYChannels(); for(int y = 0; y < lstDataY.size(); y++) // Loop through the data channels and display them { int ValueDisplay = 0; // Flag if we should display this channel as a graph or not 0 = yes, 1 = no const IDataChannel* pChannel = pLap->GetChannel(lstDataY[y]); if(!pChannel || !pChannel->IsValid()) continue; const DATA_CHANNEL eType = lstDataY[y]; // Determine if this Data Channel is one that we only want to display the values for for (int u = 0; u < sizeof lstDataY; u++) { if (eType == m_pLapSupplier->GetDisplayOptions().m_PlotPrefs[u].iDataChannel && m_pLapSupplier->GetDisplayOptions().m_PlotPrefs[u].iPlotView == false) { // We have found a display only channel. Let's prevent the graph from displaying ValueDisplay = 1; break; } } if(mapMinY.find(eType) == mapMinY.end()) { mapMinY[eType] = min(pChannel->GetMin(),m_pLapSupplier->GetDataHardcodedMin(eType)); mapMaxY[eType] = max(pChannel->GetMax(),m_pLapSupplier->GetDataHardcodedMax(eType)); } else { mapMinY[eType] = min(pChannel->GetMin(),mapMinY[eType]); mapMaxY[eType] = max(pChannel->GetMax(),mapMaxY[eType]); } if (ValueDisplay == 0) { setY.insert(eType); } } if(pDataX) { dMaxX = max(dMaxX, pDataX->GetMax()); dMinX = min(dMinX, pDataX->GetMin()); eX = pDataX->GetChannelType(); } } } if(setY.size() <= 0) { DrawSelectLapsPrompt(); return; } RECT rcSpot; int iSegmentHeight=0; { RECT rcClient; GetClientRect(OGL_GetHWnd(), &rcClient); iSegmentHeight = RECT_HEIGHT(&rcClient) / setY.size(); rcSpot.left = 0; rcSpot.top = 0; rcSpot.right = RECT_WIDTH(&rcClient); rcSpot.bottom = iSegmentHeight; } int iPos = 0; // y-channel graphing loop start for(set<DATA_CHANNEL>::iterator i = setY.begin(); i != setY.end(); i++) { vector<HIGHLIGHTDATA> lstMousePointsToDraw; glViewport(rcSpot.left,rcSpot.top,RECT_WIDTH(&rcSpot),RECT_HEIGHT(&rcSpot)); // now we have the bounds of all the laps we've looked at, so let's draw them glPushMatrix(); glLoadIdentity(); glScalef(1.0f, 0.90f, 1.0f); // Let's scale it so that graphs don't touch each other. glOrtho(dMinX, dMaxX,mapMinY[*i], mapMaxY[*i],-1.0,1.0); // draw horizontal guide lines and text on the background. Yes this should probably go into a function, Art ;) // first draw the starting guideline { float flLine = m_pLapSupplier->GetGuideStart(*i, mapMinY[*i], mapMaxY[*i]); LineColor(); // Pick guideline color, based upon chosen color scheme glLineWidth(1); // Added by KDJ. Skinny lines for guidelines. glBegin(GL_LINE_STRIP); glVertex2f(dMinX,flLine); glVertex2f(dMaxX,flLine); glEnd(); LineColor(); // Pick guideline color, based upon chosen color scheme char szText[256]; GetChannelString(*i, sfLapOpts.eUnitPreference, flLine, szText, NUMCHARS(szText)); DrawText(dMinX, flLine, szText); } // now draw the rest of them for(float flLine = m_pLapSupplier->GetGuideStart(*i, mapMinY[*i], mapMaxY[*i]) + m_pLapSupplier->GetGuideStep(*i, mapMinY[*i], mapMaxY[*i]); flLine < mapMaxY[*i]; flLine += m_pLapSupplier->GetGuideStep(*i, mapMinY[*i], mapMaxY[*i])) { LineColor(); // Pick guideline color, based upon chosen color scheme glLineWidth(1); // Added by KDJ. Skinny lines for guidelines. glBegin(GL_LINE_STRIP); glVertex2f(dMinX,flLine); glVertex2f(dMaxX,flLine); glEnd(); LineColor(); // Pick guideline color, based upon chosen color scheme char szText[256]; GetChannelString(*i, sfLapOpts.eUnitPreference, flLine, szText, NUMCHARS(szText)); DrawText(dMinX, flLine, szText); } // draw vertical guide lines and text on the background only if at 1.0X magnification if (sfLapOpts.iZoomLevels != 0) { } else { // first draw the starting guideline { float flLine = m_pLapSupplier->GetGuideStartX(eX, dMinX, dMaxX); LineColor(); // Pick guideline color, based upon chosen color scheme glLineWidth(1); dCenterOvalX = 0.0f; // Center oval at the origin dCenterOvalY = 0.0f; // dCenterOvalX = (dMaxX - dMinX) / 2.0f + dMinX; // dCenterOvalY = (mapMaxY[*i] - mapMinY[*i]) / 2.0f + mapMinY[*i]; // If this is for drawing the Traction Circle, let's draw a circle as well (Oval really) if (eX == DATA_CHANNEL_X_ACCEL || eX == DATA_CHANNEL_Y_ACCEL || eX == DATA_CHANNEL_Z_ACCEL) { float w, h; w = 3.0f; h = 3.0f; drawOval (dCenterOvalX, dCenterOvalY, w, h); // Draw 1.5G circle w = 1.0f; h = 1.0f; drawOval (dCenterOvalX, dCenterOvalY, w, h); // Draw 0.5G circle w = 2.0f; h = 2.0f; drawOval (dCenterOvalX, dCenterOvalY, w, h); // Draw 1.0G circle // Now let's draw a vertical line at the origin glBegin(GL_LINE_STRIP); glVertex3f(0.0f,mapMinY[*i],0); glVertex3f(0.0f,mapMaxY[*i],0); glEnd(); } else { glBegin(GL_LINE_STRIP); glVertex3f(flLine,mapMinY[*i],0); glVertex3f(flLine,mapMaxY[*i],0); glEnd(); } LineColor(); // Pick guideline color, based upon chosen color scheme char szText[256]; GetChannelString(eX, sfLapOpts.eUnitPreference, flLine, szText, NUMCHARS(szText)); DrawText(flLine, mapMinY[*i]-12, szText); } // now draw the rest of them for(float flLine = m_pLapSupplier->GetGuideStartX(eX, dMinX, dMaxX) + m_pLapSupplier->GetGuideStepX(eX, dMinX, dMaxX); flLine < dMaxX; flLine += m_pLapSupplier->GetGuideStepX(eX, dMinX, dMaxX)) { LineColor(); // Pick guideline color, based upon chosen color scheme glLineWidth(1); glBegin(GL_LINE_STRIP); glVertex3f(flLine,mapMinY[*i],0); glVertex3f(flLine,mapMaxY[*i],0); glEnd(); LineColor(); // Pick guideline color, based upon chosen color scheme char szText[256]; GetChannelString(eX, sfLapOpts.eUnitPreference, flLine, szText, NUMCHARS(szText)); DrawText(flLine, mapMinY[*i]-12, szText); } } // Set up the non-zoomed/panned view for the map GLdouble rgModelviewMatrix[16]; GLdouble rgProjMatrix[16]; GLint rgViewport[4]; { // Now that the matrices are correct, let's graph them. glGetDoublev(GL_MODELVIEW_MATRIX, rgModelviewMatrix); glGetDoublev(GL_PROJECTION_MATRIX, rgProjMatrix); glGetIntegerv(GL_VIEWPORT, rgViewport); POINT ptMouse; if(GetMouse(&ptMouse) && m_pLapSupplier->IsHighlightSource(m_iSupplierId)) { // The mouse is in our window, so panning and zooming are active! const double dCenterX = (dMinX + dMaxX)/2; // Center of X for scaling transformation double dScaleAmt = pow(1.08,sfLapOpts.iZoomLevels); GLdouble dXShift,dYShift,dZShift; // Project the window shift stuff so we know how far to translate the view dYShift = 0; // No Y shift or zoom for Map Plot. gluUnProject(sfLapOpts.flWindowShiftX/dScaleAmt,0,0,rgModelviewMatrix,rgProjMatrix,rgViewport,&dXShift,&dYShift,&dZShift); // Set up to perform the ZOOM function for DATA PLOT. double dTranslateShiftX; dTranslateShiftX= dCenterX; glTranslated(dTranslateShiftX,0,0); // Translate the map to origin on x-axis only glScaled(dScaleAmt,1.0,1.0); // No scaling of Y-axis on Data Plot. glTranslated(-dTranslateShiftX,0,0); // Now put the map back in its place // Panning functionality glTranslated(dXShift-dMinX,0,0); // Offset for this is still slight wrong, but the best for now. // Now having shifted, let's get our new model matrices glGetDoublev(GL_MODELVIEW_MATRIX, rgModelviewMatrix); glGetDoublev(GL_PROJECTION_MATRIX, rgProjMatrix); glGetIntegerv(GL_VIEWPORT, rgViewport); } } Vector2D ptHighlight; // the (x,y) coords in unit-space that we want to highlight. Example: for a speed-distance graph, x would be in distance units, y in velocities. POINT ptMouse; if(GetMouse(&ptMouse) && m_pLapSupplier->IsHighlightSource(m_iSupplierId)) { // The mouse is in our window... we make our own highlighter, ignoring anything that got sent to us GLdouble dX,dY,dZ; gluUnProject(ptMouse.x,ptMouse.y,0,rgModelviewMatrix,rgProjMatrix,rgViewport,&dX,&dY,&dZ); ptHighlight = V2D(dX,0); } for(int x = 0; x < lstLaps.size(); x++) { CExtendedLap* pLap = lstLaps[x]; const IDataChannel* pDataX = pLap->GetChannel(m_pLapSupplier->GetXChannel()); const IDataChannel* pDataY = pLap->GetChannel(*i); if(pDataX && pDataY) { // tracking what we want to highlight float dBestLength = -1; float dTimeToHighlight = -1; const vector<DataPoint>& lstPointsX = pDataX->GetData(); const vector<DataPoint>& lstPointsY = pDataY->GetData(); // srand((int)pLap); // <-- makes sure that we randomize the colours consistently, so that lap plots don't change colour from draw to draw... float r; float g; float b; MakeColor ( pLap, &r, &g, &b ); // Function picks color to use and tells opengl to draw the following in the colour we just made up if(sfLapOpts.fDrawLines) { glLineWidth(2); // Added by KDJ. Sets the width of the line to draw. glBegin(GL_LINE_STRIP); } else { glPointSize(4.0f); glBegin(GL_POINTS); } vector<DataPoint>::const_iterator iX = lstPointsX.begin(); vector<DataPoint>::const_iterator iY = lstPointsY.begin(); while(iX != lstPointsX.end() && iY != lstPointsY.end()) { float dX; float dY; const DataPoint& ptX = *iX; const DataPoint& ptY = *iY; int iTimeUsed = 0; if(ptX.iTimeMs < ptY.iTimeMs) { iTimeUsed = ptX.iTimeMs; dX = ptX.flValue; dY = pDataY->GetValue(ptX.iTimeMs, iY); iX++; } else if(ptX.iTimeMs > ptY.iTimeMs) { iTimeUsed = ptY.iTimeMs; dX = pDataX->GetValue(ptY.iTimeMs, iX); dY = ptY.flValue; iY++; } else { iTimeUsed = ptY.iTimeMs; DASSERT(ptX.iTimeMs == ptY.iTimeMs); dX = ptX.flValue; dY = ptY.flValue; iX++; iY++; } glVertex2f(dX,dY); // if we're a highlight source, try to figure out the closest point for this lap if(m_pLapSupplier->IsHighlightSource(m_iSupplierId)) { Vector2D vPt = V2D(dX,0); Vector2D vDiff = vPt - ptHighlight; if(vDiff.Length() < dBestLength || dBestLength < 0) { dBestLength = vDiff.Length(); dTimeToHighlight = iTimeUsed; } } } glEnd(); // for each lap, draw an indicator of the closest thing to the mouse if(!m_pLapSupplier->IsHighlightSource(m_iSupplierId)) { // if we're not a source, use the given time to highlight dTimeToHighlight = m_pLapSupplier->GetLapHighlightTime(pLap); } else { m_pLapSupplier->SetLapHighlightTime(pLap, (int)dTimeToHighlight); } UpdateHighlightPointList(lstMousePointsToDraw, pLap, rgModelviewMatrix, rgProjMatrix, rgViewport, dTimeToHighlight, pDataX, pDataY); } } // end lap loop if(lstMousePointsToDraw.size() > 0) { glPushMatrix(); // <-- pushes a matrix onto the opengl matrix stack. glLoadIdentity(); // <-- makes it so that the matrix stack just converts all our coordinates directly to window coordinates glOrtho(0, RECT_WIDTH(&rcSpot),0, RECT_HEIGHT(&rcSpot),-1.0,1.0); /* <-- tells OpenGL that it should show us the part of the openGL "world" that corresponds to (0...window width, 0 ... window height). This completes the "hey opengl, just draw where we tell you to plz" part of the function */ for(int x = 0; x < lstMousePointsToDraw.size(); x++) // <-- loops through all the stupid boxes/lines we want to draw { const CExtendedLap* pLap = lstMousePointsToDraw[x].m_pLap; // <-- gets the lap data we want to draw const POINT& ptWindow = lstMousePointsToDraw[x].m_ptWindow; // <-- gets info about where in the window we want to draw the box const IDataChannel* pDataX = lstMousePointsToDraw[x].m_pDataX; // <-- gets the x channel data const IDataChannel* pDataY = lstMousePointsToDraw[x].m_pDataY; // <-- gets the y channel data float r; float g; float b; MakeColor ( pLap, &r, &g, &b ); // Function picks color to use and tells opengl to draw the following in the colour we just made up // For TIME displayed on X-axis, remove all data channel text so that user can see the trends more clearly. if (pDataX->GetChannelType() != DATA_CHANNEL_TIME) { // if we're the main screen, we want to draw some text data for each point TCHAR szLapName[256]; pLap->GetString(szLapName, NUMCHARS(szLapName)); // <-- gets the string "10:11:12 - 1:40.59 - Keith", aka the "lap name" float dTimeToHighlight = m_pLapSupplier->GetLapHighlightTime(pLap); // <-- asks the ILapSupplier interface what we should highlight TCHAR szTypeX[256]; ::GetDataChannelName(eX,szTypeX,NUMCHARS(szTypeX)); // <-- converts the data channel type into a string, like "Oil Temperature" TCHAR szTypeY[256]; ::GetDataChannelName(lstMousePointsToDraw[x].m_eChannelY, szTypeY, NUMCHARS(szTypeY)); // <-- converts the y channel into a string char szYString[256]; GetChannelString(lstMousePointsToDraw[x].m_eChannelY, sfLapOpts.eUnitPreference, pDataY->GetValue(dTimeToHighlight), szYString, NUMCHARS(szYString)); // <-- gets the actual unit string for the data channel. For speed, this might be "100.0km/h" char szXString[256]; GetChannelString(eX, sfLapOpts.eUnitPreference, pDataX->GetValue(dTimeToHighlight), szXString, NUMCHARS(szXString)); // <-- same for x channel char szText[256]; sprintf(szText, "%S - (%S @ %S) %s @ %s", szLapName, szTypeY, szTypeX, szYString, szXString); DrawText(100.0,(x+1)*GetWindowFontSize(),szText); // <-- draws the text from the bottom of the window, working upwards // we also want to draw a highlighted square DrawGLFilledSquare(ptWindow.x, ptWindow.y, 3); // <-- draws the stupid little box at ptWindow.x. // we also want to draw a highlighted LINE for that individual lap/graph combination glLineWidth(1); // Added by KDJ. Skinny line for Distance markers. glBegin(GL_LINE_STRIP); // Added by KDJ glVertex3f(ptWindow.x, 0, 0); // Added by KDJ, modified by Chas glVertex3f(ptWindow.x,rcSpot.bottom,0); // Added by KDJ } glEnd(); // Added by KDJ } glPopMatrix(); glPopMatrix(); // Should there be two of these here? } rcSpot.top += iSegmentHeight; rcSpot.bottom += iSegmentHeight; } // end y-channel data channel loop }