Source Code (Use browser search to find items of interest.)

Class Index

kspread'AIMeter (./koffice/kspread/qtai_meter.h:37)

class AIMeter : public AIBar
{
  Q_OBJECT
public:
  AIMeter(QWidget *parent,const char *name,int n=1);
  void setType(int type);

protected:
  void   drawIt( QPainter * );
  void   drawGrid( QPainter *p );

private:
  int      zx,zy,r,rs;
  double   fzx,fzy,fr;
  double   amin,amax;
};

/*******************************************************************/
/********* End Draw Window Definition  *****************************/
/*******************************************************************/

kspread'AIMeter::AIMeter() (./koffice/kspread/qtai_meter.cpp:41)

AIMeter::AIMeter(QWidget *parent,const char *name,int n)
  : AIBar(parent,name,n)
{
  int i;

  for (i=0;i<8;i++) {
    color[i].setRgb( 0, 164, 0 );		
  }

  setType(AI_METER_LEVEL);
}


kspread'AIMeter::drawGrid() (./koffice/kspread/qtai_meter.cpp:53)

void AIMeter::drawGrid( QPainter *p )
{
  int w=width()*FACTOR,h=height()*FACTOR;
  QString str="";
  QWMatrix matrix;
  QWMatrix zmatrix;
  QFont font("Helvetica",10);
  QFontMetrics fm(font);
  double   azero;
  int      i;

  p->setFont(font);
  p->setPen(c_grid);
  p->setWindow(0,0,w,h);	        // defines coordinate system

  azero=(0-min)*(amax-amin)/(max-min)+amin;
  zmatrix.translate( zx, zy );	// move to center
  zmatrix.rotate(270+azero);
  p->setWorldMatrix( zmatrix );		// use this world matrix

  str.sprintf("%.2f",0.0);
  p->drawText(-fm.width(str)/2,-rs-10,str);

  matrix.translate( zx, zy );	// move to center
  matrix.rotate(270+amin);

  for (i=0;i<=scale_tile;i++) {

    p->setWorldMatrix( matrix );	// use this world matrix
    p->drawLine(0,-r,0,-rs);

    if (i==0 || i==scale_tile) {
      str.sprintf("%.2f",i*(max-min)/scale_tile+min);
      p->drawText(-fm.width(str)/2,-rs-10,str);
    }

    matrix.rotate((amax-amin)/scale_tile);
  }
}


kspread'AIMeter::drawIt() (./koffice/kspread/qtai_meter.cpp:93)

void AIMeter::drawIt( QPainter *p )
{
  QPoint   qp(0,0);
  QWMatrix matrix,pmatrix;
  int      w=width()*FACTOR;
  int      h=height()*FACTOR;
  QFont    font("Helvetica",10);
  QFontMetrics fm(font);
  int      i;
  double   aact;
  QString str="";

  zx=(int)(fzx*w);
  zy=(int)(fzy*h);
  r=(int)(fr*h);
  rs=(int)(fr*h+10);

  QPainter tmp; // for double buffering
  QPixmap  pix(width(),height());

  tmp.begin( &pix );

  tmp.setWindow(0,0,w,h);	// defines coordinate system
int    n;

  static int     bw=-1,bh=-1; // BG Buffer
  static QPixmap *bg_buf=NULL;
  QPainter bg_p;
  QColor   c;


kspread'AIMeter::setType() (./koffice/kspread/qtai_meter.cpp:188)

void AIMeter::setType(int type)
{
  switch(type) {
  case AI_METER_LEVEL:
    // Type Level Meter
    amin=60;
    amax=120;
    fzx=0.5f,fzy=1.3f,fr=0.8f;
    break;
  case AI_METER_TACHO:
    // Type Tachometer
    amin=-40;
    amax=220;
    fzx=0.5f,fzy=0.5f,fr=0.3f;
    break;
  }
}