Ejemplo n.º 1
0
LRESULT CAnimMixer::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	drawBar(1);

	CPaintDC dc(m_hWnd);

	// layout elements
	updateThisClip();

	CFontHandle oldFont = dc.SelectFont(AtlGetDefaultGuiFont());
	dc.SetTextColor(RGB(255, 255, 255));
	dc.SetTextAlign(TA_TOP|TA_LEFT);
	dc.SetBkMode(TRANSPARENT);

	if (m_thisClip)
	{
		for (sInt i = 0; i < m_thisClip->m_elements.size(); ++i)
		{
			frAnimationClip::element& elem = m_thisClip->m_elements[i];

			CRect rc;
			getElemRect(i, rc);

			dc.Draw3dRect(&rc, RGB(0, 0, 0), RGB(0, 0, 0));
			rc.DeflateRect(1, 1);
			dc.Draw3dRect(&rc, (m_curElem == i) ? RGB(4,78,51) : RGB(75,249,186), (m_curElem == i) ? RGB(75,249,186) : RGB(4, 78, 51));
			rc.DeflateRect(1, 1);
			dc.FillSolidRect(&rc, RGB(6, 158, 106));

			fr::string clipName;

			if (elem.type == 0) // curve
				clipName = "(curve)";
			else
			{
				const frAnimationClip* clp = g_graph->m_clips->getClip(elem.id);

				if (clp)
					clipName = clp->getName();
				else
					clipName = "(invalid)";
			}

			dc.DrawText(clipName, -1, &rc, DT_VCENTER|DT_CENTER|DT_SINGLELINE|DT_END_ELLIPSIS);
		}
	}
	
	dc.SelectFont(oldFont);
	drawBar(2);

  return 0;
}
Ejemplo n.º 2
0
static char* drawChar(char *buf, char *c) {
	while (*c != '\0') {
		switch (*c) {
		case '0':
			buf = drawBar(buf, 0xFF);
			break;
		case '1':
			buf = drawBar(buf, 0x00);
			break;
		}
		c++;
	}
	return buf;
}
Ejemplo n.º 3
0
/**
 * Draw all the bars of the spectrum.
 * @param heights the heights of all the bars.
 */
static void drawBars(float heights[])
{
    glPushMatrix();
    glTranslatef(-2.0, 0.0, 0.0);

    glEnableClientState(GL_VERTEX_ARRAY);
    glEnableClientState(GL_NORMAL_ARRAY);

    float w = SPECTRUM_WIDTH / NB_BANDS;
    for (unsigned i = 0; i < NB_BANDS; ++i)
    {
        glPushMatrix();
        glScalef(1.0, heights[i], 1.0);
        setBarColor(heights[i]);
        drawBar();
        glPopMatrix();

        glTranslatef(w, 0.0, 0.0);
    }

    glDisableClientState(GL_VERTEX_ARRAY);
    glDisableClientState(GL_NORMAL_ARRAY);

    glPopMatrix();
}
void ConnectionActivityDrawingArea::drawBarPoints() {
	// forall in multiPoints
	{
		std::map<double, std::vector<double> >::iterator it_multiPoints = multiPoints.begin();
		const std::map<double, std::vector<double> >::const_iterator it_multiPoints_end = multiPoints.end();
		while (it_multiPoints != it_multiPoints_end) {
			double xval = it_multiPoints->first;
			// sort into descending order
			std::sort(it_multiPoints->second.begin(), it_multiPoints->second.end());
			// forall in bar_points
			{
				int count = 0;
				std::vector<double>::const_reverse_iterator it_bar_points = it_multiPoints->second.rbegin();
				const std::vector<double>::const_reverse_iterator it_bar_points_end = it_multiPoints->second.rend();
				while (it_bar_points != it_bar_points_end) {

					//increase colours
					drawBar(xval, *it_bar_points, 0, STANDARD_COLOURS.getMainColour());
					++count;
					++it_bar_points;
				}
			}
			++it_multiPoints;
		}
	}

}
Ejemplo n.º 5
0
		void Ship2::drawOverlay() {
			glDisable(GL_LIGHTING);
			glColor3d(0.9,0.1,0.1);
			cg::Util::instance()->drawBitmapString("Player 2\n", _winWidth - 130, _winHeight - 20);
			glColor3d(1,1,1);
			std::ostringstream os;
			if (_duel) os << "Kills: " << _kills;
			else os << "Score: " << _score;
			std::string str = os.str();
			cg::Util::instance()->drawBitmapString(str, _winWidth - 130, _winHeight - 30);
			os.str("");
			os << "Lives: " << _lives;
			str = os.str();
			cg::Util::instance()->drawBitmapString(str, _winWidth - 130, _winHeight - 40);
			os.str("");
			os << "Mines: " << _mineAmmo;
			str = os.str();
			cg::Util::instance()->drawBitmapString(str, _winWidth - 70, _winHeight - 40);
			os.str("");
			os << "Speed: " << length(_physics->getVelocity()) << " Zegatrons";
			str = os.str();
			cg::Util::instance()->drawBitmapString(str, _winWidth - 130, _winHeight - 50);
			os.str("");
			cg::Util::instance()->drawBitmapString("Energy: ", _winWidth - 130, _winHeight - 60);
			int LarguraBarraEnergia = 2 + (_energy/_maxEnergy)* (_shieldbar - 2);
			cg::Vector3d corDireita = cg::Vector3d(1- (_energy/_maxEnergy), (_energy/_maxEnergy),0);
			drawBar(_winWidth - 130, _winWidth - 130 + LarguraBarraEnergia, _winHeight - 65, _winHeight - 75, cg::Vector3d(1,0,0), corDireita);
			glEnable(GL_LIGHTING);			
		}
Ejemplo n.º 6
0
void mySliderButton::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setRenderHints(QPainter::Antialiasing|QPainter::HighQualityAntialiasing);
    drawBg(&painter);
    drawBar(&painter);
    drawText(&painter);
}
Ejemplo n.º 7
0
void myCoolBar::paintEvent(QPaintEvent *e)
{
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    drawBar(&painter);
    drawFilledRegion(&painter);
    drawIndicator(&painter);
}
int SoView2DLiftChart::drawAllStructuresInOneColumn(int x1, int y1) {
   int min, max;
   for (T_ConstStructureIterator iter = _liftChartData->structureSortedBegin(); iter != _liftChartData->structureSortedEnd(); iter++) {
      if (structureIsVisible(iter)) {
         min = mapWorldToChart((*iter)->getMin());
         max = mapWorldToChart((*iter)->getMax());
         drawBar(*iter, x1, min + y1, x1 + 6, max + y1);
      }
   }
   return 6;
}
Ejemplo n.º 9
0
void GfxMenu::kernelDrawMenuBar(bool clear) {
	if (!clear) {
		Port *oldPort = _ports->setPort(_ports->_menuPort);
		calculateMenuWidth();
		drawBar();
		_paint16->bitsShow(_ports->_menuBarRect);
		_ports->setPort(oldPort);
	} else {
		kernelDrawStatus("", 0, 0);
	}
}
Ejemplo n.º 10
0
void ProgressBarColor::paintEvent(QPaintEvent *)
{
    //绘制准备工作,启用反锯齿
    QPainter painter(this);
    painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);

    //绘制背景
    //drawBg(&painter);
    //绘制进度
    drawBar(&painter);
}
Ejemplo n.º 11
0
void MyMerryGoRound::draw()
{
    glDisable(GL_CULL_FACE);
    glPushMatrix();

    drawBar();
    glPopMatrix();
//    srand(1); //initialize the random number generator
//    // fill up later
    glEnable(GL_CULL_FACE);
//    myspotlights.setupLights();
}
int SoView2DLiftChart::drawOneEntryPerColumn(int x1, int y1) {
   int width = 0;
   int min, max;
   for (T_ConstStructureIterator iter = _liftChartData->structureSortedBegin(); iter != _liftChartData->structureSortedEnd(); iter++) {
      if (structureIsVisible(iter)) {
         min = mapWorldToChart((*iter)->getMin());
         max = mapWorldToChart((*iter)->getMax());
         drawBar(*iter, x1 + width, min + y1, x1 + width + 6, max + y1);
         width += 6;
      }
   }
   return width;
}
Ejemplo n.º 13
0
void VUMeter::paintEvent(QPaintEvent *)
{
    //绘制准备工作,启用反锯齿,平移坐标轴中心,等比例缩放
    QPainter painter(this);
    painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
    painter.setWindow(0, 0, 100, 540);

    //绘制边框
    drawBorder(&painter);
    //绘制柱状音量
    drawBar(&painter);
    //绘制值
    drawValue(&painter);
}
Ejemplo n.º 14
0
void main(){
	
	
	int hr;
	int min;
	int sec;
	getTime(&hr, &min, &sec);
	
	clrScreen();
	drawBar();
	makeInterrupt21();
	loadProgram();

}
Ejemplo n.º 15
0
/*!
  Draw a sample

  \param painter Painter
  \param xMap x map
  \param yMap y map
  \param canvasRect Contents rect of the canvas
  \param boundingInterval Bounding interval of sample values
  \param index Index of the sample
  \param sample Value of the sample

  \sa drawSeries()
*/
void QwtPlotBarChart::drawSample( QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &canvasRect, const QwtInterval &boundingInterval,
    int index, const QPointF &sample ) const
{
    QwtColumnRect barRect;

    if ( orientation() == Qt::Horizontal )
    {
        const double barHeight = sampleWidth( yMap, canvasRect.height(),
            boundingInterval.width(), sample.y() );

        const double x1 = xMap.transform( baseline() );
        const double x2 = xMap.transform( sample.y() );

        const double y = yMap.transform( sample.x() );
        const double y1 = y - 0.5 * barHeight;
        const double y2 = y + 0.5 * barHeight;

        barRect.direction = ( x1 < x2 ) ?
            QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft;

        barRect.hInterval = QwtInterval( x1, x2 ).normalized();
        barRect.vInterval = QwtInterval( y1, y2 );
    }
    else
    {
        const double barWidth = sampleWidth( xMap, canvasRect.width(),
            boundingInterval.width(), sample.y() );

        const double x = xMap.transform( sample.x() );
        const double x1 = x - 0.5 * barWidth;
        const double x2 = x + 0.5 * barWidth;

        const double y1 = yMap.transform( baseline() );
        const double y2 = yMap.transform( sample.y() );

        barRect.direction = ( y1 < y2 ) ?
            QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop;

        barRect.hInterval = QwtInterval( x1, x2 );
        barRect.vInterval = QwtInterval( y1, y2 ).normalized();
    }

    drawBar( painter, index, sample, barRect );
}
Ejemplo n.º 16
0
void violet::HUD::drawHealth(float health, int bottomBasePoint) {
	VideoMode screen = m_videoManager->getVideoMode();
	const int barLeft = screen.Width / 12;
	const int barLen = screen.Width / 4;
	const int barHeight = m_videoManager->RegularText->getHeight() / 4;

	const int indX = screen.Width / 24;
	m_resources->HealthIndicator->X = indX;
	m_resources->HealthIndicator->Y = bottomBasePoint;

	m_resources->HealthIndicator->draw(false, false);

	GLfloat bcolor[] = { 1.0f, 1.0f, 1.0f, 0.3f };
	GLfloat fcolor1[] = { 1.0f, 0.0f, 0.0f, 1.0f };
	GLfloat fcolor2[] = { 1.0f, 1.0f, 0.0f, 1.0f };

	drawBar(barLeft, bottomBasePoint, barLen, barHeight, health, bcolor,
			fcolor1, fcolor2);
}
/*!
  \return Icon for representing a bar on the legend

  \param index Index of the bar
  \param size Icon size
  
  \return An icon showing a bar
  \sa drawBar(), legendData()
 */
QwtGraphic QwtPlotMultiBarChart::legendIcon( int index,
    const QSizeF &size ) const
{
    QwtColumnRect column;
    column.hInterval = QwtInterval( 0.0, size.width() - 1.0 );
    column.vInterval = QwtInterval( 0.0, size.height() - 1.0 );

    QwtGraphic icon;
    icon.setDefaultSize( size );
    icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );

    QPainter painter( &icon );
    painter.setRenderHint( QPainter::Antialiasing,
        testRenderHint( QwtPlotItem::RenderAntialiased ) );

    drawBar( &painter, -1, index, column );

    return icon;
}
Ejemplo n.º 18
0
int main(void)
{
  int c, whitespace;
  int state = OUT;
  int len = 0;

  while ((c = getchar()) != EOF) {
    whitespace = (c == '\t' || c == '\n' || c == ' ');
    if (whitespace && state == IN) {
      state = OUT;
      drawBar(len);
      len = 0;
    } else {
      state = IN;
      len++;
    }
  }
  return 0;
}
Ejemplo n.º 19
0
void violet::HUD::drawExperience(float experience, int levelPoints,
		int bottomBasePoint) {
	VideoMode screen = m_videoManager->getVideoMode();
	const int barLen = screen.Width / 4;
	const int barLeft = 2 * screen.Width / 3;
	const int barHeight = m_videoManager->RegularText->getHeight() / 4;

	const int indX = screen.Width - screen.Width / 24;
	m_resources->LevelUpIndicator->X = indX;
	m_resources->LevelUpIndicator->Y = bottomBasePoint;

	m_resources->LevelUpIndicator->draw(false, false);

	GLfloat bcolor[] = { 1.0f, 1.0f, 1.0f, 0.3f };
	GLfloat fcolor1[] = { 0.0f, 0.0f, 1.0f, 1.0f };
	GLfloat fcolor2[] = { 0.0f, 1.0f, 1.0f, 1.0f };

	drawBar(barLeft, bottomBasePoint, barLen, barHeight, experience, bcolor,
			fcolor1, fcolor2);
}
Ejemplo n.º 20
0
LRESULT CAnimMixer::OnFrameChanged(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	if (m_flags & 8) // follow mode
	{
		RECT rc;
		sInt mapped = mapTime(m_curFrame);

		GetClientRect(&rc);

		if (mapped >= rc.right * 7 / 8) // need to scroll right
			processScroll(mapped - rc.right / 8, sTRUE);
		else if (mapped < 0) // need to scroll left
			processScroll(mapped - rc.right * 7 / 8, sTRUE);
	}

	m_curFrame = lParam;
	drawBar();
  
  return 0;
}
Ejemplo n.º 21
0
void QmitkHistogram::draw(QPainter *painter, const QwtScaleMap &xMap,
                          const QwtScaleMap &yMap, const QRectF &) const
{
  const QwtIntervalSeriesData &iData = m_Data->data;

  painter->setPen(QPen(m_Data->color));

  //const int x0 = xMap.transform(baseline());
  const int y0 = yMap.transform(baseline());

  for ( int i = 0; i < (int)iData.size(); i++ )
  {
    const int y2 = yMap.transform(iData.sample(i).value);
    if ( y2 == y0 )
      continue;

    int x1 = xMap.transform(iData.sample(i).interval.minValue());
    int x2 = xMap.transform(iData.sample(i).interval.maxValue());
    if ( x1 > x2 )
      qSwap(x1, x2);

    if ( i < (int)iData.size() - 2 )
    {
      const int xx1 = xMap.transform(iData.sample(i+1).interval.minValue());
      const int xx2 = xMap.transform(iData.sample(i+1).interval.maxValue());

      if ( x2 == qMin(xx1, xx2) )
      {
        const int yy2 = yMap.transform(iData.sample(i+1).value);
        if ( yy2 != y0 && ( (yy2 < y0 && y2 < y0) ||
          (yy2 > y0 && y2 > y0) ) )
        {
          // One pixel distance between neighbored bars
          x2--;
        }
      }
    }
    drawBar(painter, Qt::Vertical,
      QRect(x1, y0, x2 - x1, y2 - y0) );
  }
}
void VehicleSelectionView::drawUnitProfileInfo(const Surface &dest, const iXY &pos, short int unitType)
{
    if (unitType == -1) {
        return;
    }

    const UnitProfile *profile = UnitProfileInterface::getUnitProfile(unitType);

    iXY       loc       = pos;
    const int gapSpace  = 10;
    const int barOffset = 105;
    int       barLength = getClientRect().getSizeX() - barOffset;

    dest.bltStringShadowed(loc, "Hit Points", Color::white, Color::black);
    drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(profile->hit_points) / float(maxHitPoints));
    loc.y += gapSpace;

    dest.bltStringShadowed(loc, "Attack Power", Color::white, Color::black);
    drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(profile->attack_factor) / float(maxAttackFactor));
    loc.y += gapSpace;

    dest.bltStringShadowed(loc, "Attack Range", Color::white, Color::black);
    drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(sqrt(profile->attack_range)) / float(maxAttackRange));
    loc.y += gapSpace;

    dest.bltStringShadowed(loc, "Defend Range", Color::white, Color::black);
    drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(sqrt(profile->defend_range)) / float(maxDefendRange));
    loc.y += gapSpace;

    dest.bltStringShadowed(loc, "Speed", Color::white, Color::black);
    drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(profile->speed_factor + profile->speed_rate) / float(maxTotalSpeed));
    loc.y += gapSpace;

    dest.bltStringShadowed(loc, "Reload Time", Color::white, Color::black);
    drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(profile->reload_time) / float(maxReloadTime));
    loc.y += gapSpace;

    dest.bltStringShadowed(loc, "Regen Time", Color::white, Color::black);
    drawBar(dest, iXY(loc.x + barOffset, loc.y), barLength, float(profile->regen_time) / float(maxRegenTime));
    loc.y += gapSpace;

}
Ejemplo n.º 23
0
void Chart::drawFullGraphBar(boolean relativeToOffset) {
    for( int i = 0 ; i < _numValues ; i++ ) {

        int x = _x1+(i*_step);


        int offsetPx = _y2;
		if(relativeToOffset) {
			offsetPx = _y2 - abs(_offset * _verticalRatio);
		}



        int value = constrain(  _y2-valueToPixel(_values[i]),
        						_y1,
        						_y2 );

	    drawBar(x, value, offsetPx);

        preventLCDBufferOverflow();
    }
}
Ejemplo n.º 24
0
/*!
   \return Icon representing a bar or the chart on the legend

   When the legendMode() is LegendBarTitles the icon shows
   the bar corresponding to index - otherwise the bar
   displays the default symbol.

   \param index Index of the legend entry 
   \param size Icon size

   \sa setLegendMode(), drawBar(), 
       QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
 */
QwtGraphic QwtPlotBarChart::legendIcon( 
    int index, const QSizeF &size ) const
{
    QwtColumnRect column;
    column.hInterval = QwtInterval( 0.0, size.width() - 1.0 );
    column.vInterval = QwtInterval( 0.0, size.height() - 1.0 );

    QwtGraphic icon;
    icon.setDefaultSize( size );
    icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );

    QPainter painter( &icon );
    painter.setRenderHint( QPainter::Antialiasing,
        testRenderHint( QwtPlotItem::RenderAntialiased ) );

    int barIndex = -1;
    if ( d_data->legendMode == QwtPlotBarChart::LegendBarTitles )
        barIndex = index;
        
    drawBar( &painter, barIndex, QPointF(), column );

    return icon;
}
Ejemplo n.º 25
0
 void VarItemDelegate::paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const {
 
 
   if (index.isValid() && index.model()!=0) {
     VarItem * item=(VarItem*)(((VarTreeModel*)index.model())->itemFromIndex (index));
     if (item!=0) {
       VarPtr dt=item->getVarType();
       if (dt!=0) {
         /*if ((dt->getFlags() & VARTYPE_FLAG_PERSISTENT) != 0x00) {
           //there's a persistent editor on top!
           //don't draw anything!
           return;
         }*/
         dt->paint(this,painter,option,index);
         if ((item->getColFlags() & (GUI_COLUMN_FLAG_RANGEBARS)) != 0) {
           drawBar(dt,painter,option,index);
         }
         return;
       }
     }
   }
   QItemDelegate::paint(painter,option,index);
 }
Ejemplo n.º 26
0
void drawBench(void)
{
	mvstack.push(model_view);
		model_view *= Translate(0.0f, 2.25f, 0.0f);
		drawPlank();
		model_view *= Translate(0.0f, -1.25f, 0.0f);
		drawPlank();
	model_view = mvstack.pop();

	mvstack.push(model_view);
		model_view *= RotateX(90);
		model_view *= Translate(0.0f, 1.0f, 0.0f);
		drawPlank();
		model_view *= Translate(0.0f, 1.25f, 0.0f);
		drawPlank();
	model_view = mvstack.pop();

	mvstack.push(model_view);
		model_view *= Scale(1.0f, 1.5f, 1.0f);
		model_view *= Translate(-5.0f, 0.0f, -0.25f);
		drawBar();
		model_view *= Translate(10.0f, 0.0f, 0.0f);
		drawBar();
	model_view = mvstack.pop();

	mvstack.push(model_view);
		model_view *= RotateX(90);
		model_view *= Translate(-5.0f, 1.25f, 0.25f);
		drawBar();
		model_view *= Translate(10.0f, 0.0f, 0.0f);
		drawBar();
		model_view *= Translate(0.0f, 1.36f, 1.0f);
		model_view *= Scale(1.0f, 1.0f, 0.66f);
		model_view *= RotateX(-90);
		drawBar();
		model_view *= Translate(-10.0f, 0.0f, 0.0f);
		drawBar();
	model_view = mvstack.pop();
}
Ejemplo n.º 27
0
void HistogramItem::draw(QPainter *painter, const QwtScaleMap &xMap, 
    const QwtScaleMap &yMap, const QRect &) const
{
    const QwtIntervalData &iData = d_data->data;

    painter->setPen(QPen(d_data->color));

    const int x0 = xMap.transform(baseline());
    const int y0 = yMap.transform(baseline());

    for ( int i = 0; i < (int)iData.size(); i++ )
    {
        if ( d_data->attributes & HistogramItem::Xfy )
        {
            const int x2 = xMap.transform(iData.value(i));
            if ( x2 == x0 )
                continue;

            int y1 = yMap.transform( iData.interval(i).minValue());
            int y2 = yMap.transform( iData.interval(i).maxValue());
            if ( y1 > y2 )
                qSwap(y1, y2);

            if ( i < (int)iData.size() - 2 )
            {
                const int yy1 = yMap.transform(iData.interval(i+1).minValue());
                const int yy2 = yMap.transform(iData.interval(i+1).maxValue());

                if ( y2 == qwtMin(yy1, yy2) )
                {
                    const int xx2 = xMap.transform(
                        iData.interval(i+1).minValue());
                    if ( xx2 != x0 && ( (xx2 < x0 && x2 < x0) ||
                                          (xx2 > x0 && x2 > x0) ) )
                    {
                       // One pixel distance between neighboured bars
                       y2++;
                    }
                }
            }

            drawBar(painter, Qt::Horizontal, QRect(x0, y1, x2 - x0, y2 - y1));
        }
        else    // this is used
        {
            const int y2 = yMap.transform(iData.value(i));
            if ( y2 == y0 )
                continue;

            int x1 = xMap.transform(iData.interval(i).minValue());
            int x2 = xMap.transform(iData.interval(i).maxValue());
            if ( x1 > x2 )
                qSwap(x1, x2);

            if ( i < (int)iData.size() - 2 )
            {
                const int xx1 = xMap.transform(iData.interval(i+1).minValue());
                const int xx2 = xMap.transform(iData.interval(i+1).maxValue());

                if ( x2 == qwtMin(xx1, xx2) )
                {
                    const int yy2 = yMap.transform(iData.value(i+1));
                    if ( yy2 != y0 && ( (yy2 < y0 && y2 < y0) ||
                                    (yy2 > y0 && y2 > y0) ) )
                    {
                        // One pixel distance between neighboured bars
                        x2--;
                    }
                }
            }
            drawBar(painter, Qt::Vertical, QRect(x1, y0, x2 - x1, y2 - y0) );
        }
    }
}
Ejemplo n.º 28
0
	ProgressBar &draw()
	{
		resetCursor();
		drawBar();
		return *this;
	}
/*!
  Draw a grouped sample

  \param painter Painter
  \param xMap x map
  \param yMap y map
  \param canvasRect Contents rectangle of the canvas
  \param index Index of the sample to be painted
  \param sampleWidth Boundng width for all bars of the smaple
  \param sample Sample 

  \sa drawSeries(), sampleWidth()
*/
void QwtPlotMultiBarChart::drawGroupedBars( QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &canvasRect, int index, double sampleWidth,
    const QwtSetSample& sample ) const
{
    Q_UNUSED( canvasRect );

    const int numBars = sample.set.size();
    if ( numBars == 0 )
        return;

    if ( orientation() == Qt::Vertical )
    {
        const double barWidth = sampleWidth / numBars;

        const double y1 = yMap.transform( baseline() );
        const double x0 = xMap.transform( sample.value ) - 0.5 * sampleWidth;

        for ( int i = 0; i < numBars; i++ )
        {
            const double x1 = x0 + i * barWidth;
            const double x2 = x1 + barWidth;

            const double y2 = yMap.transform( sample.set[i] );

            QwtColumnRect barRect;
            barRect.direction = ( y1 < y2 ) ?
                QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop;

            barRect.hInterval = QwtInterval( x1, x2 ).normalized();
            if ( i != 0 )
                barRect.hInterval.setBorderFlags( QwtInterval::ExcludeMinimum );

            barRect.vInterval = QwtInterval( y1, y2 ).normalized();

            drawBar( painter, index, i, barRect );
        }
    }
    else
    {
        const double barHeight = sampleWidth / numBars;

        const double x1 = xMap.transform( baseline() );
        const double y0 = yMap.transform( sample.value ) - 0.5 * sampleWidth;

        for ( int i = 0; i < numBars; i++ )
        {
            double y1 = y0 + i * barHeight;
            double y2 = y1 + barHeight;

            double x2 = xMap.transform( sample.set[i] );

            QwtColumnRect barRect;
            barRect.direction = x1 < x2 ?
                QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft;

            barRect.hInterval = QwtInterval( x1, x2 ).normalized();

            barRect.vInterval = QwtInterval( y1, y2 );
            if ( i != 0 )
                barRect.vInterval.setBorderFlags( QwtInterval::ExcludeMinimum );

            drawBar( painter, index, i, barRect );
        }
    }
}
/*!
  Draw a stacked sample

  \param painter Painter
  \param xMap x map
  \param yMap y map
  \param canvasRect Contents rectangle of the canvas
  \param index Index of the sample to be painted
  \param sampleWidth Width of the bars
  \param sample Sample 

  \sa drawSeries(), sampleWidth()
*/
void QwtPlotMultiBarChart::drawStackedBars( QPainter *painter,
    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    const QRectF &canvasRect, int index, 
    double sampleWidth, const QwtSetSample& sample ) const
{
    Q_UNUSED( canvasRect ); // clipping the bars ?

    const int numBars = sample.set.size();
    if ( numBars == 0 )
        return;

    QwtInterval::BorderFlag borderFlags = QwtInterval::IncludeBorders;

    if ( orientation() == Qt::Vertical )
    {
        const double x1 = xMap.transform( sample.value ) - 0.5 * sampleWidth;
        const double x2 = x1 + sampleWidth;

        const bool increasing = qwtIsIncreasing( yMap, sample.set );

        QwtColumnRect bar;
        bar.direction = increasing ?
            QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop;

        bar.hInterval = QwtInterval( x1, x2 ).normalized();

        double sum = baseline();

        const int numBars = sample.set.size();
        for ( int i = 0; i < numBars; i++ )
        {
            const double si = sample.set[ i ];
            if ( si == 0.0 )
                continue;

            const double y1 = yMap.transform( sum );
            const double y2 = yMap.transform( sum + si );

            if ( ( y2 > y1 ) != increasing )
            {
                // stacked bars need to be in the same direction
                continue;
            }

            bar.vInterval = QwtInterval( y1, y2 ).normalized();
            bar.vInterval.setBorderFlags( borderFlags );

            drawBar( painter, index, i, bar );

            sum += si;

            if ( increasing )
                borderFlags = QwtInterval::ExcludeMinimum;
            else
                borderFlags = QwtInterval::ExcludeMaximum;
        }
    }
    else
    {
        const double y1 = yMap.transform( sample.value ) - 0.5 * sampleWidth;
        const double y2 = y1 + sampleWidth;

        const bool increasing = qwtIsIncreasing( xMap, sample.set );

        QwtColumnRect bar;
        bar.direction = increasing ?
            QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft;
        bar.vInterval = QwtInterval( y1, y2 ).normalized();

        double sum = baseline();

        for ( int i = 0; i < sample.set.size(); i++ )
        {
            const double si = sample.set[ i ];
            if ( si == 0.0 )
                continue;

            const double x1 = xMap.transform( sum );
            const double x2 = xMap.transform( sum + si );

            if ( ( x2 > x1 ) != increasing )
            {
                // stacked bars need to be in the same direction
                continue;
            }

            bar.hInterval = QwtInterval( x1, x2 ).normalized();
            bar.hInterval.setBorderFlags( borderFlags );

            drawBar( painter, index, i, bar );

            sum += si;

            if ( increasing )
                borderFlags = QwtInterval::ExcludeMinimum;
            else
                borderFlags = QwtInterval::ExcludeMaximum;
        }
    }
}