bool TextImp::getExtents(double& dMinX, double& dMinY, double& dMaxX, double& dMaxY) { PlotViewImp* pPlot = getPlot(); if (pPlot == NULL) { return false; } double dScreenX = 0; double dScreenY = 0; pPlot->translateDataToScreen(mLocation.mX, mLocation.mY, dScreenX, dScreenY); QFontMetrics ftMetrics(mFont); int iHeight = ftMetrics.height(); int iWidth = ftMetrics.width(mText); double dScreenExtentX = dScreenX + iWidth; double dScreenExtentY = dScreenY + iHeight; pPlot->translateDataToWorld(mLocation.mX, mLocation.mY, dMinX, dMinY); pPlot->translateScreenToWorld(dScreenExtentX, dScreenExtentY, dMaxX, dMaxY); return true; }
void CurveImp::draw() { if (isVisible() == false) { return; } unsigned int numPoints = mPoints.size(); if (numPoints == 0) { return; } glColor3ub(mColor.red(), mColor.green(), mColor.blue()); glLineWidth(mLineWidth); if (mLineStyle != SOLID_LINE) { glEnable(GL_LINE_STIPPLE); if (mLineStyle == DASHED) { glLineStipple(3, 0x3f3f); } else if (mLineStyle == DOT) { glLineStipple(2, 0x1111); } else if (mLineStyle == DASH_DOT) { glLineStipple(2, 0x11ff); } else if (mLineStyle == DASH_DOT_DOT) { glLineStipple(2, 0x24ff); } } glBegin(GL_LINE_STRIP); PlotViewImp* pPlot = getPlot(); VERIFYNRV(pPlot != NULL); double dWorldX = 0.0; double dWorldY = 0.0; unsigned int i = 0; for (i = 0; i < numPoints; i++) { LocationType point = mPoints.at(i); pPlot->translateDataToWorld(point.mX, point.mY, dWorldX, dWorldY); glVertex2d(dWorldX, dWorldY); } glEnd(); if (mLineStyle != SOLID_LINE) { glDisable(GL_LINE_STIPPLE); } glLineWidth(1); if (isSelected() == true) { for (i = 0; i < numPoints; i++) { LocationType point = mPoints.at(i); double dScreenX = 0; double dScreenY = 0; pPlot->translateDataToScreen(point.mX, point.mY, dScreenX, dScreenY); double dX1 = dScreenX - 4; double dY1 = dScreenY - 4; double dX2 = dScreenX + 4; double dY2 = dScreenY + 4; double dPixelX1 = 0.0; double dPixelY1 = 0.0; double dPixelX2 = 0.0; double dPixelY2 = 0.0; pPlot->translateScreenToWorld(dX1, dY1, dPixelX1, dPixelY1); pPlot->translateScreenToWorld(dX2, dY2, dPixelX2, dPixelY2); glBegin(GL_POLYGON); glVertex2d(dPixelX1, (dPixelY1 + dPixelY2) / 2); glVertex2d((dPixelX1 + dPixelX2) / 2, dPixelY1); glVertex2d(dPixelX2, (dPixelY1 + dPixelY2) / 2); glVertex2d((dPixelX1 + dPixelX2) / 2, dPixelY2); glEnd(); } } }