Logo Search packages:      
Sourcecode: kcollectd version File versions  Download package

void Graph::drawAll (  ) [private]

draw the widgets contents.

this covers a grid, the graph istself, x- and y-label and a header

Definition at line 620 of file graph.cc.

References drawGraph(), and fetchAllData().

Referenced by paintEvent().

{
  const int numgraphs =  glist.size();

  if (numgraphs) {
    if (!data_is_valid)
      fetchAllData ();

    // clear
    QPainter paint(&offscreen);
    paint.setFont(font);
    paint.eraseRect(0, 0, contentsRect().width(), contentsRect().height());
    //paint.fillRect(0, 0, contentsRect().width(), contentsRect().height(), QColor(245, 245, 245));
    
    // margin calculations
    // place for labels at the left and two line labels below
    const QFontMetrics &fontmetric = paint.fontMetrics();
    const QFontMetrics smallmetric = QFontMetrics(small_font);
    const QFontMetrics headermetric = QFontMetrics(header_font);

    time_iterator minor_x, major_x, label_x;
    QString format_x;
    bool center_x;
    findXGrid(graph_rect.width(), format_x, center_x, minor_x, major_x, label_x);
    drawHeader(paint);
    
    int n = 0;
    for(graph_list::iterator i = begin(); i != end(); ++n, ++i) {
      const int top = i->top() - contentsRect().top();
      const int bottom = i->bottom() - contentsRect().top();

      // y-scaling
      double base;
      Range y_range = i->minmax_adj(&base);
      if (!y_range.isValid())
      continue;
      
      // geometry
      const int xlabel_base = bottom + marg + smallmetric.ascent();
      const int legend_base = top + graph_height + fontmetric.ascent();
      
      // panel area
      QRect panelrect(graph_rect.left(), top, graph_rect.width(), bottom-top);
      
      // graph-background
      paint.fillRect(panelrect, color_graph_bg);
      
      // draw minor, major, graph
      drawXLabel(paint, xlabel_base, graph_rect.left(), graph_rect.right(), 
          label_x, format_x, center_x);
      drawXLines(paint, panelrect, minor_x, color_minor);
      drawYLines(paint, panelrect, y_range, base/10, color_minor);
      drawXLines(paint, panelrect, major_x, color_major);
      drawYLines(paint, panelrect, y_range, base, color_major);
      drawYLabel(paint, panelrect, y_range, base);
      drawGraph(paint, panelrect, *i, y_range.min(), y_range.max());
      drawLegend(paint, marg, legend_base, box_size, *i);
    }
    paint.end();
    // copy to screen
    QPainter(this).drawPixmap(contentsRect(), offscreen);
  } else {
    QPainter paint(this);
    paint.eraseRect(contentsRect());
    const QString label(i18n("Drop sensors from list here"));
    const int labelwidth = paint.fontMetrics().width(label);
    paint.drawText((width()-labelwidth)/2, height()/2, label);
    paint.end();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index