Example #1
2
void MainWindow::funS()
{
    QLabel* l = new QLabel;
    l->setWindowTitle("Fun");
    l->setFixedSize(765, 500);

    QObject::connect( this, SIGNAL( closeSignal() ), l, SLOT( close() ) );

    QRect rect(l->contentsRect());
    QPainter painter;

    QImage resultImage(rect.size(), QImage::Format_ARGB32_Premultiplied);

    painter.begin(&resultImage);
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.eraseRect(rect);
    painter.drawImage(rect, resultImage);
    painter.end();

    painter.begin(&resultImage);
    painter.setCompositionMode(QPainter::CompositionMode_Darken);

    for(int i = 0; i < 765; i++)
    {
        if(i<256)
            painter.setPen(QPen(QColor(255, i, 0), 1));
        else if(i < 512)
            painter.setPen(QPen(QColor(511-i, 255, i-256), 1));
            else
                painter.setPen(QPen(QColor(i-512, 765-i, 255), 1));

        painter.drawLine(i, 0, i, 500);
    }
    painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
    painter.drawImage(rect, resultImage);
    painter.end();

    l->setPixmap(QPixmap::fromImage(resultImage));
    l->show();

    QObject::connect( this, SIGNAL( closeSignal() ), l, SLOT( close() ) );
}
Example #2
0
void Widget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);
    QPainter painter;
    QPainterPath path;
    QPen pen(Qt::darkGray);
    painter.begin(this);
    pen.setWidth(3);
    pen.setCapStyle(Qt::RoundCap);
    pen.setJoinStyle(Qt::RoundJoin);
    painter.setBrush(Qt::darkGray);
    painter.drawRect(ui->crossBlock->x(),ui->crossBlock->y(),ui->crossBlock->width(),ui->crossBlock->height());
    pen.setColor(Qt::black);
    painter.setPen(pen);
    painter.drawLine(ui->crossBlock->x()+1,ui->crossBlock->y()+1,ui->crossBlock->x()+ui->crossBlock->width(),ui->crossBlock->y()+ui->crossBlock->height());
    painter.drawLine(ui->crossBlock->x()+1,ui->crossBlock->y()+ui->crossBlock->height(),ui->crossBlock->x()+ui->crossBlock->width(),ui->crossBlock->y()+1);
    pen.setColor(Qt::yellow);
    painter.setPen(pen);
    int mca_x = ui->mcaImage->x();
    int mca_y = ui->mcaImage->y();
    int mcb_x = ui->mcbImage->x();
    int mcb_y = ui->mcbImage->y();
    int mc_width = ui->mcaImage->width();
    int mc_height = ui->mcaImage->height();
    painter.setBrush(Qt::NoBrush);
//    painter.drawRoundedRect(mca_x,mca_y,mc_width,mc_height,5,5);
//    painter.drawRoundedRect(mcb_x,mcb_y,mc_width,mc_height,5,5);
    painter.drawRect(mca_x,mca_y,mc_width,mc_height);
    painter.drawRect(mcb_x,mcb_y,mc_width,mc_height);
//    painter.setPen(Qt::NoPen);
    painter.setBrush(Qt::NoBrush);
    painter.eraseRect(mca_x-5,mca_y-5,mc_width*0.1,mc_height*1.2);
    painter.eraseRect(mcb_x+mc_width*0.9+5,mcb_y-5,mc_width*0.1+2,mc_height*1.2);
    path.moveTo(mca_x+mc_width*0.1,mca_y);
    path.arcTo(QRectF(mca_x+mc_width*0.1-mc_height/2,mca_y,mc_height,mc_height),90,180);
    pen.setColor(Qt::yellow);
    painter.setPen(pen);
    painter.drawPath(path);
    path.moveTo(mcb_x+mc_width*0.8,mcb_y);
    path.arcTo(QRectF(mcb_x+mc_width*0.9-mc_height/2,mcb_y,mc_height,mc_height),90,-180);
    painter.drawPath(path);
    int smallRectWidth =mc_width/6;
    int smallRectHeight= mc_height/4;
    painter.setBrush(Qt::yellow);
    painter.drawRect(mca_x+mc_width*0.3-smallRectWidth,mca_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight);
    painter.drawRect(mca_x+mc_width-smallRectWidth*0.5-smallRectWidth,mca_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight);
    painter.drawRect(mca_x+mc_width*0.3-smallRectWidth,mca_y+mc_height-smallRectHeight*1.3,smallRectWidth,smallRectHeight);
    painter.drawRect(mca_x+mc_width-smallRectWidth*0.5-smallRectWidth,mca_y+mc_height-smallRectHeight*1.3,smallRectWidth,smallRectHeight);
    painter.drawRect(QRectF(mcb_x+smallRectWidth*0.5,mcb_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight));
    painter.drawRect(QRectF(mcb_x+smallRectWidth*0.5,mcb_y+mc_height-smallRectHeight*0.3-smallRectHeight,smallRectWidth,smallRectHeight));
    painter.drawRect(QRectF(mcb_x+mc_width*0.7,mcb_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight));
    painter.drawRect(QRectF(mcb_x+mc_width*0.7,mcb_y+mc_height-smallRectHeight*0.3-smallRectHeight,smallRectWidth,smallRectHeight));
    QSize Size = painter.fontMetrics().size(Qt::TextSingleLine, str);
    painter.setPen(Qt::white);
    painter.drawText(QPointF(mca_x+mc_width/2-Size.width()/2,mca_y+mc_height/2+Size.height()/2),str);
    painter.drawText(QPointF(mcb_x+mc_width/2-Size.width()/2,mcb_y+mc_height/2+Size.height()/2),str);
    painter.end();

}
Example #3
0
void PlotWidget::resizeEvent(QResizeEvent *event)
{
    double maxX=XCoord[0], maxY=YCoord[0], minX=XCoord[0], minY=YCoord[0];
    uint i;
    int longX=width()-80;
    int longY=height()-140;
    for(i=0; i< XCoord.size(); i++){
        if(minX>XCoord[i]) minX=XCoord[i];
        if(maxX<XCoord[i]) maxX=XCoord[i];
        if(minY>YCoord[i]) minY=YCoord[i];
        if(maxY<YCoord[i]) maxY=YCoord[i];
    }
    double x,y;
    imagen=QImage(longX+30,longY+30,QImage::Format_RGB32);
    QPainter painter;
    painter.begin(&imagen);
    painter.eraseRect(0,0,longX+30,longY+30);
    painter.setPen(Qt::blue);
    painter.setBrush(Qt::blue);
    for(i=0;i<=XCoord.size();i++){
        x=(XCoord[i]-minX)*longX/(maxX-minX)+30;
        y=(YCoord[i]-minY)*longY/(maxY-minY);
        painter.drawEllipse(x,longY-y,5,5);
    }
    painter.setPen(Qt::black);
    if(LinearFitEnabled){
        painter.drawLine(30,longY- ((minX*Plot_m+Plot_b)-minY)*longY/(maxY-minY),longX+30,longY-((maxX*Plot_m+Plot_b)-minY)*longY/(maxY-minY));
    }
    painter.end();
    ImageLabel->setPixmap(QPixmap::fromImage(imagen));
    //  ImageLabel->adjustSize();
    QWidget::resizeEvent(event);
}
Example #4
0
void CropFrame::paintEvent(QPaintEvent*)
{
    QPixmap bmp(this->width(), this->height());
    QPainter p;
    p.begin(&bmp);

    p.eraseRect(0, 0, this->width(), this->height());

    // draw the background pixmap
    p.drawPixmap(m_pixmapX, m_pixmapY, *m_pixmap);

    if (m_drawRec)
    {
        // draw the rectangle
        p.setPen(QPen(m_color, 2));
        p.drawRect(m_cropRegion);
        // draw the crosshairs
        int midX = m_cropRegion.left() + m_cropRegion.width() / 2;
        int midY = m_cropRegion.top()  + m_cropRegion.height() / 2;
        p.drawLine(midX - 10, midY, midX + 10, midY);
        p.drawLine(midX, midY - 10, midX, midY + 10);
    }
    p.end();

    QPainter newp(this);
    newp.drawPixmap(0, 0, bmp);
}
Example #5
0
void Drawboard::setupBuffer()
{
    QPixmap* newBuffer = new QPixmap(width(), height());
    QPainter* newPainter = new QPainter(newBuffer);

    newPainter->setBackgroundMode(Qt::OpaqueMode);
    newPainter->setBackground(Qt::white);

    newPainter->setRenderHint(QPainter::Antialiasing);
    newPainter->setRenderHint(QPainter::SmoothPixmapTransform);

    newPainter->eraseRect(newBuffer->rect());
    if (buffer != NULL)
    {
        int w = std::min(buffer->width(), newBuffer->width());
        int h = std::min(buffer->height(), newBuffer->height());
        newPainter->drawPixmap(0, 0, *buffer, 0, 0, w, h);
    }

    newPainter->setBrush(QColor(255, 0, 0, 128));
    newPainter->setPen(QColor(255, 0, 0, 255));

    delete painter;
    delete buffer;
    buffer = newBuffer;
    painter = newPainter;

    update();
}
Example #6
0
void Widget::display()
{
    delete layout();
    QSpacerItem *space1 = new QSpacerItem(100,10);
    QSpacerItem *space2 = new QSpacerItem(100,10);
    QSpacerItem *space3 = new QSpacerItem(10,10);

    QHBoxLayout *hlayout = new QHBoxLayout;
    hlayout->addSpacerItem(space1);
    hlayout->addWidget(integral);
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(numerator);
    if(this->isVisibleDenominator){
        QPixmap lineP(max(lineSizePixels((QString)numerator->text()),lineSizePixels((QString)denominator->text())),2);
        QPainter paint;
        paint.begin(&lineP);
        paint.setBrush(QBrush(Qt::black));
        paint.eraseRect(0,0,1000,1000);
        paint.drawRect(0,0,1000,1000);
        paint.end();
        line->setPixmap(lineP);
        layout->addWidget(line);
        layout->addWidget(denominator);
    }
    hlayout->addLayout(layout);
    hlayout->addSpacerItem(space3);
    hlayout->addWidget(diff);
    hlayout->addSpacerItem(space2);
    QVBoxLayout *vlayout = new QVBoxLayout;
    vlayout->addLayout(hlayout);
    vlayout->addWidget(answer);
    setLayout(vlayout);
}
Example #7
0
void Graph::paintEvent(QPaintEvent *)
{
    QPainter painter;
    painter.begin(this);
    painter.setBackground(background);
    painter.eraseRect(rect());
    QPoint *points = new QPoint[MAX_DATA_LENGTH +2];
    points[0] = QPoint(0,150);
    points[MAX_DATA_LENGTH +1] = QPoint(MAX_DATA_LENGTH,150);
    for (int s = 0; s < MAX_DATA_LENGTH; s++){
        points[s +1] = QPoint(s,100 - data.at(data.length() - s -1));
    }
    painter.setPen(gridPen);
    painter.setBrush(filler);
    for (int s = 0; s < MAX_DATA_LENGTH / 30; s++){
        painter.drawLine(MAX_DATA_LENGTH - 30 * (s+1), 0,MAX_DATA_LENGTH - 30 * (s+1), 100);
    }
    for (int s = 0; s < 10; s++){
        painter.drawLine(0, 10*s,MAX_DATA_LENGTH, 10*s);
    }
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(circlePen);
    painter.drawPolygon(points,MAX_DATA_LENGTH +2);
    painter.end();
    delete points;
}
//Input Port #0: Buffer_Size = 1, Params_Type = ProcessorMulti_Processor_Control_Params, Data_Type = ProcessorMulti_Processor_Control_Data
//Input Port #1: Buffer_Size = 1, Params_Type = SensorInternalEvent_Sensor_Joystick_Params, Data_Type = SensorInternalEvent_Sensor_Joystick_Data
bool DECOFUNC(processMultiDrainData)(void * paramsPtr, void * varsPtr, QVector<QVector<void *> > drainParams, QVector<QVector<void *> > drainData)
{
	VisualizationMulti_VisualMisc_ControlJoy_Params * params=(VisualizationMulti_VisualMisc_ControlJoy_Params *)paramsPtr;
	VisualizationMulti_VisualMisc_ControlJoy_Vars * vars=(VisualizationMulti_VisualMisc_ControlJoy_Vars *)varsPtr;
	QVector<ProcessorMulti_Processor_Control_Params *> drainparams_0; copyQVector(drainparams_0,drainParams[0]);
	QVector<SensorInternalEvent_Sensor_Joystick_Params *> drainparams_1; copyQVector(drainparams_1,drainParams[1]);
	QVector<ProcessorMulti_Processor_Control_Data *> draindata_0; copyQVector(draindata_0,drainData[0]);
	QVector<SensorInternalEvent_Sensor_Joystick_Data *> draindata_1; copyQVector(draindata_1,drainData[1]);
	if(draindata_0.size()==0){return 0;}
	if(draindata_1.size()==0){return 0;}
	/*======Please Program below======*/
	/*
	Function: process draindata_index.
	*/
    ProcessorMulti_Processor_Control_Data* controldata = draindata_0.front();
    SensorInternalEvent_Sensor_Joystick_Data* joystick_data = draindata_1.front();

    if(controldata->isManualControl == 1)//manual control
    {
        QImage image(vars->width, vars->height, QImage::Format_ARGB32);

        QPainter painter;

        //vars->joystick_label->resize(vars->width, vars->height);
        painter.begin(&image);
        painter.setBackground(QBrush(QColor(241,241,241)));
        painter.eraseRect(0,0, vars->width, vars->height);

         if(joystick_data->forward)
            painter.drawImage(vars->width/2-16, vars->height/2-56, vars->forwardArrowImg);

        if(joystick_data->left)
            painter.drawImage(vars->width/2 -56, vars->height/2-16, vars->leftArrowImg);

        if(joystick_data->right)
            painter.drawImage(vars->width/2+24, vars->height/2-16, vars->rightArrowImg);

        if(joystick_data->back)
            painter.drawImage(vars->width/2-16, vars->height/2+24, vars->backArrowImg);
        painter.end();

        vars->label->setPixmap(QPixmap::fromImage(image));
    }
    else //Auto control
    {
        QFont serifFont("Times", vars->fontSize);
        vars->label->setFont(serifFont);
        QPalette pa;
        pa.setColor(QPalette::WindowText,Qt::red);
        vars->label->setPalette(pa);
        //vars->label->setAlignment(Qt::AlignLeft);

        QString outputstr = QString("Left_Motor: %1\nRight_Motor: %2\n").arg(controldata->left_motor).arg(controldata->right_motor);
        vars->label->setText(outputstr);
    }

    //vars->label->setFixedHeight(250);
	return 1;
}
void RubberbandWidget::mouseReleaseEvent( QMouseEvent* )
{
    if ( on ) {
	QPainter p ( this );
	p.eraseRect( rect() );
    }
    on = FALSE;
    setMouseTracking( FALSE );
}
Example #10
0
void WLinePlot::drawContent(QPainter &p, bool completeRedraw) {

    completeRedraw=true;

    QArray<float>::Iterator xIt, yIt;

    p.eraseRect(p.window());

    if (!traces.isEmpty() && xData.count()>0) {

        if (wrapAround) {

            p.setPen(SolidLine);

            // cycle traces and draw them
            for (WGraphTrace *trace=traces.first();
                    trace !=0; trace=traces.next())
                if (trace->isVisible()) {

                    p.setPen(trace->getPen());

                    xIt=xData.begin();
                    yIt=trace->getData().begin();
                    p.moveTo(mapToViewCoords(*xIt,*yIt));
                    for (++xIt, ++yIt; xIt<xData.end(); ++xIt, ++yIt)
                        p.lineTo(mapToViewCoords(*xIt,*yIt));
                }

            // drawing new cursor at newPos+1
            if (cursorPos<traceLength()-1) {
                int x1 = mapToViewCoords(xData[cursorPos],0).x();
                int x2 = mapToViewCoords(xData[cursorPos+1],0).x()+1;
                p.fillRect(x1,p.window().top(),x2-x1,p.window().height(),red);
            }
        } else {

            float *x=xData.data(), *y;

            for (WGraphTrace *trace=traces.first();
                    trace !=0; trace=traces.next())
                if (trace->isVisible()) {

                    y=trace->getData().data();

                    p.setPen(trace->getPen());
                    p.moveTo(mapToViewCoords(x[0],y[(cursorPos+1) %
                                                    traceLength()]));

                    for (int i=1; i<traceLength(); i++)
                        p.lineTo(mapToViewCoords(x[i],y[(i+cursorPos+1) %
                                                        traceLength()]));
                }
        }
    }
}
Example #11
0
void SVGFrame::paintEvent ( QPaintEvent* event )
{
	if ( repaint && !drawImg && !empty )
	{
		QPainter p ( this );
		p.setViewport ( 0, 0, width(), height() );
		p.eraseRect ( 0, 0, width(), height() );
		renderer->render ( &p );
	}
	QFrame::paintEvent ( event );
}
Example #12
0
void MapPanel::paintEvent(QPaintEvent *)
{

    QPainter painter;
    painter.begin(this);
    painter.eraseRect(0,0,width(),height());
    painter.translate(off_x,off_y);
    painter.scale(scale,scale);
    painter.drawImage(0,0,mapMagager.getImage());
    painter.end();
}
void GraphicsContext::clearRect(const FloatRect& rect)
{
    if (paintingDisabled())
        return;

    QPainter *p = m_data->p();
    QPainter::CompositionMode currentCompositionMode = p->compositionMode();
    p->setCompositionMode(QPainter::CompositionMode_Source);
    p->eraseRect(rect);
    p->setCompositionMode(currentCompositionMode);
}
Example #14
0
//イメージファイルの出力
bool SXBSchView::exportImage(const QString& fname)
{
    m_pDoc->resetSelect();
    updateViewBuffer(true);

    int w = SheetSize().width();
    int h = SheetSize().height();

    QPixmap buffer(w,h);

    QPainter painter;
    painter.begin(&buffer);
    QRect rcClip = QRect(0,0,w,h);
    SRect srcClip =SRect(0,0,w,h);

    //    int currentScale = m_viewScale;
    //    int currentScaleMul = m_viewScaleMul;

    //    m_viewScale = 1;
    //    m_viewScaleMul = 1;
    SSize size = m_pDoc->SheetSize();

    //#ifdef _WINDOWS
    //    painter.setBackgroundColor(Qt::color0);
    //    painter.eraseRect(0,0,w,h);
    //    g_drawFrame(&painter,size,rcClip,Qt::color1,1,1);
    //    drawMainXBSchObj(&painter,DRAW_MONO,&srcClip,1,1);
    //#else
    painter.setBackground(Qt::white);
    painter.eraseRect(0,0,w,h);
    g_drawFrame(&painter,size,rcClip,Qt::black,1,1);
    //    drawMainXBSchObj(&painter,DRAW_ON,&srcClip);

    QSettings *settings = g_cfg.getSettings();
    settings->beginGroup("PrintOption");
    bool color = settings->value("Color",true).toBool();
    settings->endGroup();
    drawMainXBSchObj(&painter,(color ? DRAW_ON : DRAW_MONO),&srcClip,false,1,1);
    //#endif
    //    m_viewScale = currentScale;
    //    m_viewScaleMul = currentScaleMul;
    bool result = buffer.save(fname);


    //qDebug("SXBSchView::exportImage(const QString& fname)");

    update();    //画面の更新を強制
    return result;
}
QPixmap QSettingColorTableItem::CreatePixmap() const
{
	if (m_pSetting == NULL || (m_pSetting->GetType() & 0xF) != Setting::SettingTypeColor)
		return QPixmap();
	else
	{
		QPixmap bmpImage(sizeHint().height() - 4, sizeHint().height() - 4);
		QPainter dcImage;
		QColor clrBackground(m_pSetting->GetValue().strValue);
		dcImage.begin(&bmpImage, table()->viewport());
		dcImage.setBackgroundColor(clrBackground.isValid() ? clrBackground : QColor(0, 0, 0));
		dcImage.eraseRect(bmpImage.rect());
		dcImage.drawRect(bmpImage.rect());
		dcImage.end();
		return bmpImage;
	}
}
Example #16
0
void doPaint(QPainter & p)
{
    QRgb rgb = qRgb(161, 161, 161);

    p.setBackground(QBrush(rgb));
    p.eraseRect(0, 0, LCD_W, LCD_H);

    if (1) {
#if !defined(PCBTARANIS)
        rgb = qRgb(0, 0, 0);
        p.setPen(rgb);
        p.setBrush(QBrush(rgb));
#endif

#if defined(PCBTARANIS)
        unsigned int previousDepth = 0xFF;
#endif

        for (int y=0; y<LCD_H; y++) {
#if defined(PCBTARANIS)
            unsigned int idx = (y/2) * LCD_W;
#else
            unsigned int idx = (y/8) * LCD_W;
            unsigned int mask = (1 << (y%8));
#endif
            for (int x=0; x<LCD_W; x++, idx++) {
#if !defined(PCBTARANIS)
                if (lcd_buf[idx] & mask) {
                    p.drawPoint(x, y);
                }
#else
                unsigned int z = (y & 1) ? (lcd_buf[idx] >> 4) : (lcd_buf[idx] & 0x0F);
                if (z) {
                    if (z != previousDepth) {
                        previousDepth = z;
                        rgb = qRgb(161-(z*161)/15, 161-(z*161)/15, 161-(z*161)/15);
                        p.setPen(rgb);
                        p.setBrush(QBrush(rgb));
                    }
                    p.drawPoint(x, y);
                }
#endif
            }
        }
    }
Example #17
0
void PlotWidget::makePlot( void )
{
    if(LinearFitEnabled){
        Information="";
        QTextStream out(&Information);
        out << "y(x)="  <<Plot_m<<"x"<<"+"<<Plot_b<< endl;
        out << "R^2=" << Plot_RSqu << endl;
    }
    InformationLabel->setText(Information);
    
    
    double maxX=XCoord[0], maxY=YCoord[0], minX=XCoord[0], minY=YCoord[0];
    uint i;
    int longX=width()-80;
    int longY=height()-140;
    for(i=0; i< XCoord.size(); i++){
        if(minX>XCoord[i]) minX=XCoord[i];
        if(maxX<XCoord[i]) maxX=XCoord[i];
        if(minY>YCoord[i]) minY=YCoord[i];
        if(maxY<YCoord[i]) maxY=YCoord[i];
    }
    double x,y;
    imagen=QImage(longX+40,longY+40,QImage::Format_RGB32);
    QPainter painter;
    painter.begin(&imagen);
    painter.eraseRect(0,0,longX+40,longY+40);
    painter.setPen(Qt::blue);
    painter.setBrush(Qt::blue);
    for(i=0;i<=XCoord.size();i++){
        x=(XCoord[i]-minX)*longX/(maxX-minX)+30;
        y=(YCoord[i]-minY)*longY/(maxY-minY);
        painter.drawEllipse(x,longY-y,5,5);
    }
    painter.setPen(Qt::black);
    if(LinearFitEnabled){
        painter.drawLine(30,longY- ((minX*Plot_m+Plot_b)-minY)*longY/(maxY-minY),longX+30,longY-((maxX*Plot_m+Plot_b)-minY)*longY/(maxY-minY));
    }
    painter.end();
    ImageLabel->setPixmap(QPixmap::fromImage(imagen));
}
//バッファの再描画
//渡される無効エリアの座標はコンテンツ座標系
void SXBSchView::drawBuffer(int x,int y,int clipx,int clipy, int clipw, int cliph )
{
    //    qDebug("SXBSchView::drawBuffer\n");
    QPainter painter;
    QRect rcClip = QRect(clipx,clipy,clipw,cliph);
    QRect rcClipSheet = ContentsToSheet(rcClip);
    SRect srcClipSheet =SRect(rcClipSheet.left(),rcClipSheet.top(),rcClipSheet.width(),rcClipSheet.height());
    //qDebug() << m_viewBuffer.size();
    painter.begin(&m_viewBuffer);
    painter.setRenderHint(QPainter::TextAntialiasing);

    painter.translate(-x,-y);
    painter.eraseRect(clipx,clipy,clipw,cliph);

    //    painter.setClipping(true);
    clipx -= x;
    clipy -= y;
    //    painter.setClipRect(clipx,clipy,clipw,cliph);
    SSize size = m_pDoc->SheetSize();
    g_drawFrame(&painter,size,rcClip,QColor("#7E2020"),m_viewScale,m_viewScaleMul);
    if(m_bDisplayGrid) {
        drawGrid(&painter,rcClipSheet,QColor("#FC4343"));
    }
    drawMainXBSchObj(&painter,DRAW_ON,&srcClipSheet,m_fEditHighLight, m_viewScale,m_viewScaleMul);

    if((m_moveOption == MOVE_OPTION_COMPONENT_NAME)  || (m_moveOption == MOVE_OPTION_COMPONENT_NUM)) {
        int modeOption = 0;
        if(m_moveOption == MOVE_OPTION_COMPONENT_NAME) {
            modeOption = DRAW_INH_PARTNAME;
        } else {
            modeOption = DRAW_INH_PARTNUM;
        }
        drawTempXBSchObj(&painter,DRAW_TEMP|modeOption,&srcClipSheet);
    }

    painter.end();
}
Example #19
0
void Hruler::paintEvent(QPaintEvent *e)
{
	if (m_doc->isLoading())
		return;
	QString tx = "";
	double sc = m_view->scale();
	Scaling = sc;
	QFont ff = font();
	ff.setPointSize(6);
	setFont(ff);
	QPainter p;
	p.begin(this);
	p.setClipRect(e->rect());
	p.setFont(font());
	
	drawMarks(p);

	if (textEditMode)
	{
		int rectX1 = textPosToLocal(Extra);
		int rectX2 = textPosToLocal(ItemEndPos-ItemPos-RExtra);
		p.eraseRect(QRect(QPoint(rectX1, 1), QPoint(rectX2, 15)));
		p.drawLine(rectX1, 16, rectX2, 16);
		p.save();
		p.setRenderHints(QPainter::Antialiasing, true);
		if (Revers)
		{
			p.translate( textPosToLocal(0), 0);
			p.scale(-1, 1);
			p.translate( textPosToLocal(Extra) - textPosToLocal(ItemEndPos-ItemPos-RExtra), 0);
			p.translate(-textPosToLocal(0), 0);
		}
		for (int CurrCol = 0; CurrCol < Cols; ++CurrCol)
		{
			double ColWidth = (textWidth() - ColGap * (Cols - 1)) / Cols;
			double Pos = (ColWidth + ColGap) * CurrCol;
			double EndPos = Pos + ColWidth;
			drawTextMarks(Pos, EndPos, p);
			
			p.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
			int xPos = textPosToLocal(Pos);
			p.drawLine(xPos, topline, xPos, bottomline);
			if (CurrCol == 0)
			{
				p.drawLine(xPos, 15, (xPos+4), 15);
				p.drawLine(xPos, topline, (xPos+4), topline);
			}
			
			p.setPen(QPen(Qt::blue, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
			
			xPos = textPosToLocal(Pos+First+Indent);
			QPolygon cr;
			cr.setPoints(3, xPos, midline, xPos+3, topline, xPos-3, topline);
			p.drawPolygon(cr);

			xPos = textPosToLocal(Pos+Indent);
			QPolygon cr2;
			cr2.setPoints(3, xPos, midline, xPos+3, bottomline, xPos-3, bottomline);
			p.drawPolygon(cr2);
			
			xPos = textPosToLocal(Pos+RMargin);
			QPolygon cr3;
			cr3.setPoints(3, xPos, topline, xPos, bottomline, xPos-3, midline);
			p.drawPolygon(cr3);

			if (TabValues.count() != 0)
			{
				p.setPen(QPen(Qt::black, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
				for (int yg = 0; yg < signed(TabValues.count()); yg++)
				{
					xPos = textPosToLocal(Pos+TabValues[yg].tabPosition);
					if (Pos+TabValues[yg].tabPosition < EndPos)
					{
						switch (static_cast<int>(TabValues[yg].tabType))
						{
							case 0:
								if (Revers)
								{
									p.save();
									p.translate(Pos + TabValues[yg].tabPosition,0);
									p.scale(-1,1);
									p.drawLine(0, tabline, 0, bottomline);
									p.drawLine(0, bottomline, 8, bottomline);
									p.restore();
								}
								else
								{
									p.drawLine(xPos, tabline, xPos, bottomline);
									p.drawLine(xPos, bottomline, xPos+8, bottomline);
								}
								break;
							case 1:
								if (Revers)
								{
									p.save();
									p.translate(Pos+TabValues[yg].tabPosition,0);
									p.scale(-1,1);
									p.drawLine(0, tabline, 0, bottomline);
									p.drawLine(0, bottomline, -8, bottomline);
									p.restore();
								}
								else
								{
									p.drawLine(xPos, tabline, xPos, bottomline);
									p.drawLine(xPos, bottomline, xPos-8, bottomline);
								}
								break;
							case 2:
							case 3:
								p.drawLine(xPos, tabline, xPos, bottomline);
								p.drawLine(xPos-4, bottomline, xPos+4, bottomline);
								p.drawLine(xPos+3, bottomline-3, xPos+2, bottomline-3);
								break;
							case 4:
								p.drawLine(xPos, tabline, xPos, bottomline);
								p.drawLine(xPos-4, bottomline, xPos+4, bottomline);
								break;
							default:
								break;
						}
					}
				}
			}
			
			p.setPen(QPen(Qt::blue, 2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
			xPos = textPosToLocal(EndPos);
			p.drawLine(xPos, topline, xPos, bottomline);
			if (CurrCol == Cols-1)
			{
				p.drawLine(xPos, bottomline, xPos-4 , bottomline);
				p.drawLine(xPos, topline, xPos-4, topline);
			}
		}
		p.restore();
	}
	if (drawMark && !Mpressed)
	{
		drawMarker(p);
	}
	p.end();
}
void SXBSchView::print(QPrinter*  pPrinter)
{
    m_pDoc->resetSelect();
    updateViewBuffer(true);
    QPainter paint;
    if(paint.begin(pPrinter ) ) {
        int dpi;
#ifdef Q_WS_MACX
        int dpix,dpiy;;
        dpix = pPrinter->logicalDpiX();
        dpiy = pPrinter->logicalDpiY();
        dpi=((dpix < dpiy) ? dpix : dpiy);
#else
        dpi = pPrinter->resolution();
#endif

        paint.setRenderHint(QPainter::Antialiasing, true);


        //    	QRect rcPaper = pPrinter->paperRect();
        //    printf("paperRect %d,%d,%d,%d\n",rcPaper.left(),rcPaper.top(),rcPaper.width(),rcPaper.height());
        QRect rcVp = paint.viewport();
        QRect rcPg = pPrinter->pageRect();
        //    printf("pageRect %d,%d,%d,%d\n",rcPg.left(),rcPg.top(),rcPg.width(),rcPg.height());
        //    	int orientation = pPrinter->orientation();
        //    printf("orientation %d\n",orientation);

        int vpWidth, vpHeight;
        int pgLeft, pgTop, pgWidth, pgHeight;

        vpWidth    =rcVp.width();
        vpHeight = rcVp.height();

        pgLeft    =rcPg.left();
        pgTop    =rcPg.top();
        pgWidth    =rcPg.width();
        pgHeight = rcPg.height();


        //印刷時に印刷の向きを変えてもpageRect()の返す値が変わらないQtのバグ(?)の対策
        if(    	(vpWidth > vpHeight && pgWidth < pgHeight)
                ||    (vpWidth < vpHeight && pgWidth > pgHeight)    ) {
            int swapn;
            swapn = pgLeft;
            pgLeft = pgTop;
            pgTop = swapn;

            swapn = pgWidth;
            pgWidth = pgHeight;
            pgHeight = swapn;
        }

        QSettings *settings = g_cfg.getSettings();

        int leftMargin = 15;
        int topMargin = 15;
        int rightMargin = 15;
        int bottomMargin = 15;

        settings->beginGroup("PrintOption");
        bool color = settings->value("Color",true).toBool();
        settings->endGroup();


        settings->beginGroup("PrintMargin");
        topMargin = settings->value("Top",15).toInt();
        bottomMargin = settings->value("Bottom",15).toInt();
        leftMargin = settings->value("Left",15).toInt();
        rightMargin = settings->value("Right",15).toInt();
        settings->endGroup();

        if      (topMargin    < 0)   topMargin = 0;
        else if (topMargin    > 50)  topMargin = 50;
        if      (bottomMargin < 0)   bottomMargin = 0;
        else if (bottomMargin > 50)  bottomMargin = 50;
        if      (leftMargin   < 0)   leftMargin = 0;
        else if (leftMargin   > 50)  leftMargin = 50;
        if      (rightMargin  < 0)   rightMargin = 0;
        else if (rightMargin  > 50)  rightMargin = 50;

        topMargin = dpi * 10 * topMargin / 254;
        bottomMargin = dpi * 10 * bottomMargin / 254;
        leftMargin = dpi * 10 * leftMargin / 254;
        rightMargin = dpi * 10 * rightMargin / 254;




        //    printf("SXBSchView::print() dpi:%d\n",dpi);

        paint.save();

        paint.setViewTransformEnabled (true);
        paint.resetMatrix();

        SSize size = m_pDoc->SheetSize();
        int w = size.w();
        int h = size.h();

        int dw = w*10;
        int dh = h*10;
        //    p->setWindow( 0,0, dw, dh );
        //    QRect rc = paint.viewport();

        int rightWidth = vpWidth-(pgLeft+pgWidth);
        if(rightWidth < 0) rightWidth = 0;
        int bottomWidth = vpHeight-(pgTop+pgHeight);
        if(bottomWidth < 0) bottomWidth = 0;

        leftMargin -= pgLeft;
        if(leftMargin < 0)leftMargin = 0;

        topMargin -= pgTop;
        if(topMargin < 0) topMargin = 0;

        rightMargin -= rightWidth;
        if(rightMargin < 0) rightMargin = 0;

        bottomMargin -= bottomWidth;
        if(bottomMargin < 0) bottomMargin = 0;

        int vw = pgWidth-(leftMargin+rightMargin);
        int vh = pgHeight-(topMargin+bottomMargin);


        double sheetRatio=(double)w / (double)h;
        double viewRatio=(double)vw / (double)vh;

        int newW;
        int newH;

        if(sheetRatio > viewRatio) {
            newW = vw;
            newH = (int)(vw / sheetRatio);
        } else {
            newH = vh;
            newW = (int)(vh *  sheetRatio);
        }
        //    printf("newW,H=%d,%d\n",newW,newH);
        //     p->setViewport(     rc.left() + (vw-newW)/2,
        //    	    	    rc.top() + (vh-newH)/2,
        //    	    	    newW, newH );
        //    QRect rcvp = p->viewport();
        //    printf("x,y,w,h  %d,%d,%d,%d\n",rcvp.x(),rcvp.y(),rcvp.width(),rcvp.height());

        paint.setViewport( leftMargin+ (vw-newW)/2,
                           topMargin + (vh-newH)/2,
                           newW, newH );
        paint.setWindow( 0,0, dw, dh );


        //    rcvp = p->viewport();
        //    printf("x,y,w,h  %d,%d,%d,%d\n",rcvp.x(),rcvp.y(),rcvp.width(),rcvp.height());


        QRect rcClip = QRect(0,0,dw,dh);
        SRect srcClip =SRect(0,0,w,h);

        paint.setBackground(Qt::white);
        paint.eraseRect(0,0,dw,dh);
        g_drawFrame(&paint,size,rcClip,Qt::black,1,10);
        drawMainXBSchObj(&paint,(color ? DRAW_ON : DRAW_MONO)|DRAW_FOR_PRINT,&srcClip,false,1,10);
        paint.restore();

        paint.end();
    }
}
Example #21
0
void MainWindow::drawGraph(bool notEmpty)
{
    QPixmap graph(540,370);
    QPainter paint;
    paint.begin(&graph);
    paint.eraseRect(0,0,540,370);
    paint.drawLine(Ox*onePixelX,0,Ox*onePixelX,pictHeight);
    paint.drawLine(0,Oy*onePixelY,pictWidth,Oy*onePixelY);

    paint.setPen(QPen(Qt::black,3));
    for(double i = leftX;i<=rightX;i+=10.0)
        paint.drawPoint((i+Ox)*onePixelX,Oy*onePixelY);
    for(double i = leftY;i<=rightY;i+=10.0)
        paint.drawPoint(Ox*onePixelX,(i+Oy)*onePixelY);

    if(!notEmpty) {
        paint.end();
        ui->outputGraph->setPixmap(graph);
        return;
    }

    paint.setPen(QPen(Qt::green,1,Qt::SolidLine));
    paint.setRenderHint(QPainter::Antialiasing, true);
    QPainterPath path,p[3];
    bool first[4] = {1,1,1,1};

    for(double i = (double)leftX+step;i<=(double)rightX;i+=step) {
        if(!isnan(f(i))) {
            if(first[0]) {
                path.moveTo((i+Ox)*onePixelX,(f(i)+Oy)*onePixelY);
                first[0] = false;
            }
            else
                path.lineTo((i+Ox)*onePixelX,(f(i)+Oy)*onePixelY);
        }
        if(!isnan(f1(i))) {
            if(first[1]) {
                p[0].moveTo((i+Ox)*onePixelX,(f1(i)+Oy)*onePixelY);
                first[1] = false;
            }
            else
                p[0].lineTo((i+Ox)*onePixelX,(f1(i)+Oy)*onePixelY);
        }
        if(!isnan(f2(i))) {
            if(first[2]) {
                p[1].moveTo((i+Ox)*onePixelX,(f2(i)+Oy)*onePixelY);
                first[2] = false;
            }
            else
                p[1].lineTo((i+Ox)*onePixelX,(f2(i)+Oy)*onePixelY);
        }
        if(!isnan(f3(i))) {
            if(first[3]) {
                p[2].moveTo((i+Ox)*onePixelX,(f3(i)+Oy)*onePixelY);
                first[3] = false;
            }
            else
                p[2].lineTo((i+Ox)*onePixelX,(f3(i)+Oy)*onePixelY);
        }
    }
    if(ui->main->isChecked()) {
        paint.setPen(QPen(Qt::blue,1,Qt::SolidLine));
        paint.drawPath(path);
    }
    if(ui->sin->isChecked()) {
        paint.setPen(QPen(Qt::green,1,Qt::SolidLine));
        paint.drawPath(p[0]);
    }
    if(ui->cos->isChecked()) {
        paint.setPen(QPen(Qt::red,1,Qt::SolidLine));
        paint.drawPath(p[1]);
    }
    if(ui->tg->isChecked()) {
        paint.setPen(QPen(Qt::darkMagenta,1,Qt::SolidLine));
        paint.drawPath(p[2]);
    }
    paint.end();
    ui->outputGraph->setPixmap(graph);
    return;
}
Example #22
0
// Repaint the state of a window. Active or inactive windows differ
// only in the look of the titlebar. If only_label is true then only
// the label string is repainted. This is used for the titlebar
// animation with animate = TRUE.
void KMDITitleLabel::paintState(bool only_label, bool colors_have_changed,
  bool animate){
  KMDIWindow *w;
  QRect title_rect=QRect(0,0,width(),height());
  QRect r = title_rect;
  bool double_buffering = false;
  QPixmap* buffer = 0;
  int x;

//  Nice, but this would make the class KWM dependant.
//  if (r.width() <= 0 || r.height() <= 0
//      || getDecoration()!=KWM::normalDecoration)
//    return;
//  int x;

  w=(KMDIWindow *)(parent()->parent()->parent());
  is_active=w->IsSelected();

  TITLEBAR_LOOK look = options.TitlebarLook;

  if (look == H_SHADED || look == V_SHADED){
    // the new("horizontal") horizontal (and vertical) shading code
    if (colors_have_changed){
      aShadepm.resize(0,0);
      iaShadepm.resize(0,0);
    }

    // the user selected shading. Do a plain titlebar anyway if the
    // shading would be senseless (higher performance and less memory
    // consumption)
    if (is_active){
      if ( kapp->activeTitleColor
          ==  activeTitleBlend)
	look = PLAIN;
    }
    else {
      if ( kapp->inactiveTitleColor
         ==  inactiveTitleBlend)
	look = PLAIN;
    }
  }

  // the following is the old/handmade vertical shading code

//   if (options.TitlebarLook == SHADED){
//     if (is_active && shaded_pm_active && shaded_pm_active_color != myapp->activeTitleColor){
//       delete shaded_pm_active;
//       shaded_pm_active = 0;
//     }
//     if (is_active && shaded_pm_inactive && shaded_pm_inactive_color != myapp->inactiveTitleColor){
//       delete shaded_pm_inactive;
//       shaded_pm_inactive = 0;
//     }
//   }

//   if (options.TitlebarLook == SHADED
//       &&
//       (is_active && (!shaded_pm_active)
//        || (!is_active && !shaded_pm_inactive))
//       ){
//     int i,y;
//     QImage image (50, TITLEBAR_HEIGHT, 8, TITLEBAR_HEIGHT);
//     QColor col = is_active ? myapp->activeTitleColor : myapp->inactiveTitleColor;
//     for ( i=0; i<TITLEBAR_HEIGHT; i++ ){
//       image.setColor( i, col.light(100+(i-TITLEBAR_HEIGHT/2)*3).rgb());
//     }
//     for (y=0; y<TITLEBAR_HEIGHT; y++ ) {
//       uchar *pix = image.scanLine(y);
//       for (x=0; x<50; x++)
//         *pix++ = is_active ? TITLEBAR_HEIGHT-1-y : y;
//     }
//     if (is_active){
//       shaded_pm_active = new("QPixmap") QPixmap;
//       *shaded_pm_active = image;
//       shaded_pm_active_color = myapp->activeTitleColor;
//     }
//     else{
//       shaded_pm_inactive = new("QPixmap") QPixmap;
//       *shaded_pm_inactive = image;
//       shaded_pm_inactive_color = myapp->inactiveTitleColor;
//     }
//   }

  QPainter p;

  if (only_label && animate){
    double_buffering = (look == H_SHADED || look == V_SHADED || look == PIXMAP);
    titlestring_offset += titlestring_offset_delta;
    if (!double_buffering){
      if (titlestring_offset_delta > 0)
	bitBlt(this,
	       r.x()+titlestring_offset_delta, r.y(),
	       this,
	       r.x(), r.y(),
	       r.width()-titlestring_offset_delta, r.height());
      else
	bitBlt(this,
	       r.x(), r.y(),
	       this,
	       r.x()-titlestring_offset_delta, r.y(),
	       r.width()+titlestring_offset_delta, r.height());
    }
  }

  if (!double_buffering)
    p.begin( this );
  else {
    // enable double buffering to avoid flickering with horizontal shading
    buffer = new("QPixmap") QPixmap(r.width(), r.height());
    p.begin(buffer);
    r.setRect(0,0,r.width(),r.height());
  }

  QPixmap *pm;
  p.setClipRect(r);
  p.setClipping(True);

  // old handmade vertical shading code

//   if (options.TitlebarLook == SHADED || options.TitlebarLook == PIXMAP){

//     if (options.TitlebarLook == SHADED)
//       pm = is_active ? shaded_pm_active : shaded_pm_inactive;
//     else

  if (look == PIXMAP){
      pm = is_active ? options.titlebarPixmapActive: options.titlebarPixmapInactive;
      for (x = r.x(); x < r.x() + r.width(); x+=pm->width())
	p.drawPixmap(x, r.y(), *pm);
  }
  else if (look == H_SHADED || look == V_SHADED ){
    // the new("horizontal") horizontal shading code
    QPixmap* pm = 0;
    if (is_active){
      if (aShadepm.size() != r.size()){
	aShadepm.resize(r.width(), r.height());
	kwm_gradientFill( aShadepm, 
          kapp->activeTitleColor,
          activeTitleBlend, look == V_SHADED );
	//aShadepm.gradientFill( activeTitleColor, activeTitleBlend, look == V_SHADED );
      }
      pm = &aShadepm;
    }
    else {
      if (iaShadepm.size() != r.size()){
	iaShadepm.resize(r.width(), r.height());
	kwm_gradientFill( iaShadepm,
          kapp->inactiveTitleColor,
          inactiveTitleBlend, look == V_SHADED ); 
//	iaShadepm.gradientFill(inactiveTitleColor, inactiveTitleBlend,
//        look == V_SHADED );
       }
       pm = &iaShadepm;
    }

    p.drawPixmap( r.x(), r.y(), *pm );
  }
  else { // TitlebarLook == TITLEBAR_PLAIN
    p.setBackgroundColor( is_active ? 
      kapp->activeTitleColor : 
      kapp->inactiveTitleColor);
    if (only_label && !double_buffering && animate){
       p.eraseRect(QRect(r.x(), r.y(), TITLE_ANIMATION_STEP+1, r.height()));
       p.eraseRect(QRect(r.x()+r.width()-TITLE_ANIMATION_STEP-1, r.y(),
 			TITLE_ANIMATION_STEP+1, r.height()));
    }
    else {
      p.eraseRect(r);
    }
  }
  p.setClipping(False);

  if (is_active)
    qDrawShadePanel( &p, r, colorGroup(), true );

  p.setPen(is_active ? 
    kapp->activeTextColor : 
    kapp->inactiveTextColor);

  QFont fnt = kapp->generalFont;
  fnt.setPointSize(12);
  fnt.setBold(true);
  p.setFont(fnt);
  bool titlestring_too_large = 
    (p.fontMetrics().width(QString(" ")+label+" ")>r.width());
  if (titlestring_offset_delta > 0){
    if (titlestring_offset > 0
	&& titlestring_offset > r.width() - p.fontMetrics().width(QString(" ")+label+" ")){
      titlestring_offset_delta *= -1;
    }
  }
  else {
    if (titlestring_offset < 0
	&& titlestring_offset +
	p.fontMetrics().width(QString(" ")+label+" ") < r.width()){
      titlestring_offset_delta *= -1;
    }
  }

  if (!titlestring_too_large)
    titlestring_offset = 0;
  p.setClipRect(r);
  p.setClipping(True);
  p.drawText(r.x()+(options.TitleAnimation?titlestring_offset:0),
	     r.y()+p.fontMetrics().ascent(),
	     QString(" ")+label+" ");
  p.setClipping(False);
  p.end();
  if (double_buffering){
    bitBlt(this,
	   title_rect.x(), title_rect.y(),
	   buffer,
	   0,0,
	   buffer->width(), buffer->height());
    delete buffer;
  }
}
Example #23
0
void WSpacePlot::drawContent(QPainter &p,bool) {

  QBrush brush;
  QColor color;
  int hue, selectHue, s, v;
  
  paintColor.getHsv(hue,s,v);
  colorGroup().highlight().getHsv(selectHue,s,v);
  
  QArray<SpaceCell>::Iterator it;
  QArray<SpaceCell>::Iterator end=cellData.end();

  if (drawGrid) {
    p.eraseRect(p.window());
    for (it=cellData.begin(); it!=end; ++it) {
      if (it->attr & selected) {
	p.fillRect(it->rect,colorGroup().highlight());
	p.setPen(colorGroup().highlight().light());
      } else p.setPen(colorGroup().mid());
      p.drawRect(it->rect);
    } 
  } else {   

    p.setBackgroundMode(OpaqueMode);
    p.setBackgroundColor(QColor(64,64,64));
    p.fillRect(p.window(),QBrush(black,Dense6Pattern));
    
    for (it=cellData.begin(); it!=end; ++it)
      if (it->visible) 
	if (it->attr&normal) {
	  
	  float val=clampf(dataRange.scaleValue(it->data));
	  
	  if (finite(val)) {
	    
	    if (it->attr & selected) 
	      color.setHsv(selectHue,128,int((0.5+0.5*val)*255));
	    else
	      color.setHsv(hue,255,int(val*255));
	    
	    p.fillRect(it->rect,color);	
	    
	    if (it->attr&marked) {
	      if (it->attr&selected) 
		color.setHsv(hue,255,int(val*255));
	      else 
		color.setHsv(selectHue,128,int((0.5+0.5*val)*255));	    
	      p.setPen(color);
	      p.drawRect(it->rect);
	    }
	  } else 
	    p.fillRect(it->rect,QBrush(paintColor,DiagCrossPattern));
	} 
  }
  
  if (hasFocus() && QRect(QPoint(0,0),viewSize).contains(currCell)) {
    p.setRasterOp(XorROP);
    p.setPen(white);
    p.drawRect(cellData[currCell.x()+currCell.y()*viewSize.width()].rect);
    p.setRasterOp(CopyROP);
  }
  
  if (!cellLabelRect.isEmpty()) {
    p.setBackgroundMode(TransparentMode);
    p.setPen(QToolTip::palette().active().text());
    p.fillRect(cellLabelRect,QToolTip::palette().active().background());
    p.drawRect(cellLabelRect);
    p.drawText(cellLabelRect,AlignCenter,cellLabelString);
  }
}