void VisualBoardSquare::paintEvent(QPaintEvent * e)
{
    Super::paintEvent(e);
    QPainter painter(this);
    QColor c;
    c.setRgb(255,255,255);
    painter.setPen(c);
    Ficha* f=tablero.consultar(fila,columna);
    if(f)
    {
        QImage sourceImage=
                f->getColor()==COLOR_BLANCO?
                    getIcono_ficha_blanca():getIcono_ficha_roja();
        sourceImage=sourceImage.scaled(painter.device()->width(),painter.device()->height(),Qt::KeepAspectRatio);
        QRect rect=sourceImage.rect();
        QRect devrect(0,0,painter.device()->width(),painter.device()->height());
        rect.moveCenter(devrect.center());
        painter.drawImage(rect.topLeft(),sourceImage);
        if(f->esDobleMovimiento())
        {
            QImage crownImage=
                    getIcono_corona().scaled(
                        painter.device()->width()/3,
                        painter.device()->height()/3,
                        Qt::KeepAspectRatio);
            rect=crownImage.rect();
            QRect devrect2(0,0,painter.device()->width(),painter.device()->height());
            rect.moveCenter(devrect2.center());
            painter.drawImage(rect.topLeft(),crownImage);
        }
    }
}
Beispiel #2
0
void fadeButton::paintEvent( QPaintEvent * _pe )
{
	QColor col = m_normalColor;
	if( m_stateTimer.elapsed() < FadeDuration )
	{
		const float state = 1 - m_stateTimer.elapsed() / FadeDuration;
		const int r = (int)( m_normalColor.red() *
					( 1.0f - state ) +
			m_activatedColor.red() * state );
		const int g = (int)( m_normalColor.green() *
					( 1.0f - state ) +
			m_activatedColor.green() * state );
		const int b = (int)( m_normalColor.blue() *
					( 1.0f - state ) +
			m_activatedColor.blue() * state );
		col.setRgb( r, g, b );
		QTimer::singleShot( 20, this, SLOT( update() ) );
	}

	QPainter p( this );
	p.fillRect( rect(), col );

	int w = rect().right();
	int h = rect().bottom();
	p.setPen( m_normalColor.darker(130) );
	p.drawLine( w, 1, w, h );
	p.drawLine( 1, h, w, h );
	p.setPen( m_normalColor.lighter(130) );
	p.drawLine( 0, 0, 0, h-1 );
	p.drawLine( 0, 0, w, 0 );
}
Beispiel #3
0
bool QtSkin::convertAttributesToColor(const QString& aName, const QXmlAttributes& theAttributes, QColor& aColor)
{
	int redIndex=theAttributes.index("red");
	int greenIndex=theAttributes.index("green");
	int blueIndex=theAttributes.index("blue");

	if(redIndex<0 || greenIndex<0 || blueIndex<0)
	{
		setErrorMessage("Invalid attributes for color "+aName);
		return false;
	}
	else
	{
		int red, green, blue;
		if(!convertStringToInteger(theAttributes.value(redIndex), red))
		{
			setErrorMessage("Invalid red: "+theAttributes.value(redIndex)+" for "+aName);
			return false;
		}
		if(!convertStringToInteger(theAttributes.value(greenIndex), green))
		{
			setErrorMessage("Invalid green: "+theAttributes.value(greenIndex)+" for "+aName);
			return false;
		}
		if(!convertStringToInteger(theAttributes.value(blueIndex), blue))
		{
			setErrorMessage("Invalid blue: "+theAttributes.value(blueIndex)+" for "+aName);
			return false;
		}
		aColor.setRgb(red, green, blue);
	}

	return true;
}
void PlotterWindow::plotSpectr(HyperCube *ptrCube, uint dataX, uint dataY)
{

    quint16 Chnls = ptrCube->GetCountofChannels();
    qint16* pSpectrValues = new qint16[Chnls];
    try{    //если можем получить точку гиперкуба
        ptrCube->GetSpectrumPoint(dataX, dataY,pSpectrValues); // записали в pSpectrValues из гиперкуба
        QVector<double> xArr(Chnls), yArr(Chnls);
        for (quint16 i = 0; i < Chnls; ++i )
        {
           xArr[i] = i;
           yArr[i] = pSpectrValues[i];
        }

        QVector<double> sortedYArr;
        sortedYArr = yArr;
        qSort(sortedYArr);
        if (sortedYArr.first() < minY )
            minY = sortedYArr.first();
        if (sortedYArr.last() > maxY )
            maxY = sortedYArr.last();
        QString grafName;
        grafName.append("X:");
        grafName.append(QString::number(dataX));
        grafName.append(" Y:");
        grafName.append(QString::number(dataY));
        m_customPlot->setInteraction(QCP::iRangeDrag , true);
        m_customPlot->setInteraction(QCP::iRangeZoom  , true);

        m_customPlot->legend->setVisible(true);
        if (!m_hold)
            m_customPlot->clearGraphs();

        m_customPlot->addGraph();
        if (m_customPlot->graphCount() == 1) // первый график всегда черного цвета, остальные - рандомные
            m_customPlot->graph()->setPen(QPen(Qt::black));
        else
        {
           QColor color;
           int limit = 256;
           int randR = qrand() % limit;
           int randG = qrand() % limit;
           int randB = qrand() % limit;
           color.setRgb(randR,randG,randB);
           m_customPlot->graph()->setPen(QPen(color));
        }
        m_customPlot->graph()->setName(grafName);
        m_customPlot->graph()->setData(xArr,yArr);
        m_customPlot->xAxis->setRange(xArr.first(),xArr.last());
        m_customPlot->yAxis->setRange(minY,maxY);
        m_customPlot->replot();
    }catch(...){
        m_customPlot->replot();
    }
    delete pSpectrValues;



}
Beispiel #5
0
QImage edge_detector::detectEdgeImage(const QImage image, int kernel)
{
    QImage destImage = QImage( image);
    QRect rect = image.rect();
    QColor qc;

    int H = rect.height();
    int W = rect.width();
    int **a;
    qreal gradient, gangle;

    int r, g, b;
    int maxg(0);

    for (int y=0; y<H; y++) // y=1; y<H-1;
    {
        for (int x=0; x<W; x++) // x=1; x<W-1;
        {
            a = get_neighbor_pixels(image, x, y, 1, true);
            edge_detect(a, kernel, &gradient, &gangle);
            deleteArray(a, 3); //size of array allocated by get_neighbor_pixels is 3x3, 3 = (range=1)*2+1

            if ((gangle >= -22.5 && gangle < 22.5) || (gangle >= 157.5 || gangle < -157.5))
            {
                r = 0;
                g = 0;
                b = 255;
            }
            else if ((gangle >= 22.5 && gangle < 67.5) || (gangle <= -112.5 && gangle > -157.5))
            {
                r = 0;
                g = 255;
                b = 0;
            }
            else if ((gangle >= 67.5 && gangle < 112.5) || (gangle <= -67.5 && gangle > -112.5))
            {
                r = 255;
                g = 255;
                b = 0;
            }
            else if ((gangle >= 112.5 && gangle < 157.5) || (gangle <= -22.5 && gangle > -67.5))
            {
                r = 255;
                g = 0;
                b = 0;
            }

            if (gradient > maxg)
                maxg = gradient;

            qc.setRgb((int)gradient & r, (int)gradient & g, (int)gradient & b);

            destImage.setPixel( x, y, qc.rgba());
        }
    }

    //printf("gangle = %f, maxg = %d\n", gangle, maxg);
    return destImage;
}
void PicsSelectWidget::updateNumLabel()
{
	QColor back;
	switch (m_doc->getPicsWarning())
	{
	case CubeDoc::WARN_NOT_ENOUGH_PIECES: back.setRgb(255, 111, 114); break;
	case CubeDoc::WARN_VERY_LITTLE_PIECES: back.setRgb(255, 194, 63); break;
	case CubeDoc::WARN_NONE: back.setRgb(105, 255, 112); break;
	}

	m_countPalette->setColor(QPalette::Active, QPalette::Window, back);
	m_countPalette->setColor(QPalette::Inactive, QPalette::Window, back);
	m_numLabel->setPalette(*m_countPalette);

	m_numLabel->setText(QString("%1 / %2").arg(m_currentGlobalCount).arg(m_currentBuildTilesCount));

}
 void Planet::DrawPlanet(QPainter *QP)
 {
     QColor tempColor = QColor();
     tempColor.setRgb(0,255,0,255);
     QPen temppen;
     temppen = QPen(tempColor);
     QP->setPen(temppen);
     if(PFocus)
     {
         QP->drawEllipse(QPoint(Location.x()+Location.width()/2,Location.y()+Location.height()/2),Location.width()-7,Location.height()-7);
     }
     QP->drawImage(Location,PlanetImg);
     tempColor.setRgb(255,255,255,255);
     temppen = QPen(tempColor);
     QP->setPen(temppen);
     QP->drawText(QPoint(Location.x()+Location.width()/2-7,Location.y()+Location.height()/2),QString::number(Population,10)); //Set back to population
 }
Beispiel #8
0
void App::slotFlashBlackoutIndicator()
{
	QPalette pal;
	QColor bg;
	QColor fg;

	pal = m_blackoutIndicator->palette();
	bg = pal.color(QPalette::Background);
	bg.setRgb(bg.red() ^ 0xff, bg.green() ^ 0xff, bg.blue() ^ 0xff);
	pal.setColor(QPalette::Background, bg);

	fg = pal.color(QPalette::Foreground);
	fg.setRgb(fg.red() ^ 0xff, fg.green() ^ 0xff, fg.blue() ^ 0xff);
	pal.setColor(QPalette::Foreground, fg);

	m_blackoutIndicator->setPalette(pal);
}
Beispiel #9
0
QColor Tools::mixColor(const QColor &color1, const QColor &color2)
{
	QColor mixedColor;
	mixedColor.setRgb( (color1.red()   + color2.red())   / 2,
	                   (color1.green() + color2.green()) / 2,
	                   (color1.blue()  + color2.blue())  / 2 );
	return mixedColor;
}
Beispiel #10
0
QColor add_preset_color(int which_color)
{
    QColor color;

    color.setRgb(preset_colors[which_color].red, preset_colors[which_color].green, preset_colors[which_color].blue, 255);

    return (color);
}
QColor
QMMLPainter::qcolor(const MathColor &mc) const {
    QColor qc;
    if (!mc.isTransparent()) {
        qc.setRgb(mc.r(), mc.g(), mc.b());
    }
    return qc;
}
Beispiel #12
0
QColor KConfigBase::readColorEntry(const char *pKey, const QColor *pDefault) const
{
    QColor aRetColor;
    int nRed = 0, nGreen = 0, nBlue = 0;

    QString aValue = readEntry(pKey);
    if(!aValue.isEmpty())
    {
        if(aValue.at(0) == '#')
        {
            aRetColor.setNamedColor(aValue);
        }
        else
        {

            bool bOK;

            // find first part (red)
            int nIndex = aValue.find(',');

            if(nIndex == -1)
            {
                // return a sensible default -- Bernd
                if(pDefault)
                    aRetColor = *pDefault;
                return aRetColor;
            }

            nRed = aValue.left(nIndex).toInt(&bOK);

            // find second part (green)
            int nOldIndex = nIndex;
            nIndex = aValue.find(',', nOldIndex + 1);

            if(nIndex == -1)
            {
                // return a sensible default -- Bernd
                if(pDefault)
                    aRetColor = *pDefault;
                return aRetColor;
            }
            nGreen = aValue.mid(nOldIndex + 1, nIndex - nOldIndex - 1).toInt(&bOK);

            // find third part (blue)
            nBlue = aValue.right(aValue.length() - nIndex - 1).toInt(&bOK);

            aRetColor.setRgb(nRed, nGreen, nBlue);
        }
    }
    else
    {

        if(pDefault)
            aRetColor = *pDefault;
    }

    return aRetColor;
}
Beispiel #13
0
QColor GLCDColors::color(QString name)
{
    QColor color;

    if (name == "red")
    {
        color.setRgb(255, 0, 0);
    }
    else if (name == "blue")
    {
        color.setRgb(0, 32, 255);
    }
    else if (name == "white")
    {
        color.setRgb(230, 230, 230);
    }
    else if (name == "green")
    {
        color.setRgb(32, 255, 32);
    }
    else if (name == "yellow")
        color.setRgb(255,255,0);
    else if (name == "brown")
        color.setRgb(128,64,0);
    else
    {
        color.setRgb(0, 32, 255);
    }

    return color;
}
void Techni::slotHandleScheme23(){
    QColor newColor;
    newColor.setRgb(176,226,212); // mint green
    myCanvas->setColor(newColor);
    QPalette pal = ui->display->palette();
    pal.setColor(QPalette::Window, newColor);
    ui->display->setPalette(pal);
    myCanvas->changeSelectedItemColorAndThickness();
}
void Techni::slotHandleScheme14(){
    QColor newColor;
    newColor.setRgb(17,51,68); // navy
    myCanvas->setColor(newColor);
    QPalette pal = ui->display->palette();
    pal.setColor(QPalette::Window, newColor);
    ui->display->setPalette(pal);
    myCanvas->changeSelectedItemColorAndThickness();
}
void Techni::slotHandleButton8(){
    QColor newColor;
    newColor.setRgb(145,0,145); // purple
    myCanvas->setColor(newColor);
    QPalette pal = ui->display->palette();
    pal.setColor(QPalette::Window, newColor);
    ui->display->setPalette(pal);
    myCanvas->changeSelectedItemColorAndThickness();
}
void Techni::slotHandleScheme24(){
    QColor newColor;
    newColor.setRgb(111,218,236); // light blue
    myCanvas->setColor(newColor);
    QPalette pal = ui->display->palette();
    pal.setColor(QPalette::Window, newColor);
    ui->display->setPalette(pal);
    myCanvas->changeSelectedItemColorAndThickness();
}
void Techni::slotHandleScheme22(){
    QColor newColor;
    newColor.setRgb(255,232,244); // light pink
    myCanvas->setColor(newColor);
    QPalette pal = ui->display->palette();
    pal.setColor(QPalette::Window, newColor);
    ui->display->setPalette(pal);
    myCanvas->changeSelectedItemColorAndThickness();
}
Beispiel #19
0
void B9Projector::drawStatusMsg()
{
    if(mStatusMsg.size()==0 || this->isHidden())return;
	QPainter painter(&mImage);
	QColor color;
	color.setRgb(127,0,0);
	painter.setPen(color);
	int leftOffset = 10;
	int fontHeight = 10;
	int bottomOffset = height() - 10;
	int buffer = fontHeight/2.2;
	painter.setFont(QFont("arial", fontHeight));
	QRect bounds;
	bounds = painter.boundingRect(leftOffset,bottomOffset-fontHeight,width(),fontHeight,Qt::TextDontClip,mStatusMsg);
	color.setRgb(0,0,0);
	painter.fillRect(leftOffset,bottomOffset-fontHeight-buffer,bounds.width(),fontHeight+2*buffer,color);
 	painter.drawText(QPoint(leftOffset,bottomOffset),mStatusMsg);
}
Beispiel #20
0
QColor Material::getColorMaterial(int type)
{
    Material *mat = new Material();
    setMaterial(mat,type);
    Vec4 colorvec((mat->diffuse[0]),(mat->diffuse[1]),(mat->diffuse[2]));
    QColor color;
    color.setRgb(((int)(colorvec.x()*255)%256),((int)(colorvec.y()*255)%256),((int)(colorvec.z()*255)%256));
    return color;
}
void MainWindow::graphplot(QCustomPlot *customPlot,int i)
{

    QColor randcolor;
    randcolor.setRgb(rand()%255, rand()%255, rand()%255);
    ui->customPlot->addGraph();
    ui->customPlot->graph(i)->setPen(QPen(randcolor));
    ui->customPlot->graph(i)->setScatterStyle(QCPScatterStyle::ssDisc);
}
Beispiel #22
0
void MainWindow::out_period_of_index(int index)
{
    if(ui->comboBox->count()==0)
    {
        return;
    }
    extraSelections.clear();
    for(int i=0;i<periods[index].indexes.size();i++)
        selection_in_text(periods[index].indexes[i].first,periods[index].indexes[i].second,ui->open_text);


    ui->label_2->setText("Расстояния: ");
    for(int i=0;i<periods[index].dist.size();i++)
    {
        ui->label_2->setText(ui->label_2->text()+QString().sprintf("%d",periods[index].dist[i]));
        if(i+1<periods[index].dist.size())
            ui->label_2->setText(ui->label_2->text()+", ");
    }
    ui->label_2->setText(ui->label_2->text()+" сим.");


    QColor color;
    mu=periods[index].nod;
    int ind=(mu>7)?(corr_table.size()-1):(mu-1);
    calc_icx();
    calc_many_icx();
    if(icx>corr_table[ind][3] && icx<corr_table[ind][2])
        color.setRgb(102,205,0);
    else
    {
        if(icx>corr_table[ind][1] && icx<corr_table[ind][3])
            color.setRgb(255,215,0);
        else
            color.setRgb(178,34,34);
    }

    mu=periods[index].nod;
    ui->icx_label_3->setText(QString().sprintf("%f",icx));
    ui->icx_label->setText("<p style=\"color:"+color.name()+"\">"+QString().sprintf("%d",periods[index].nod)+"</p>");



}
Beispiel #23
0
bool QColorDrag::decode( QMimeSource *e, QColor &col )
{
    QByteArray data = e->encodedData( "application/x-color" );
    ushort rgba[ 4 ];
    if( data.size() != sizeof( rgba ) )
	return FALSE;
    memcpy( rgba, data.data(), sizeof( rgba ) );
    col.setRgb( rgba[ 0 ] / 0xFF, rgba[ 1 ] / 0xFF, rgba[ 2 ] / 0xFF );
    return TRUE;
}
Beispiel #24
0
/*!
 *Die Farben Haben einen Feste Reihenfolge. nach einer festen Anzahl von Aufrufen wiederholt sich die Reihenfolge
 *@return eine Farbe
*/
QColor NeuerKursEingabe::nextColor()
{
    QColor Farbe;
    switch(++nextColorint)
    {
        case 0: Farbe=Qt::red;break;
    case 1: Farbe=Qt::blue;break;
    case 2:Farbe=Qt::yellow;break;
    case 3:Farbe.setRgb(255,85,0);break;
    case 4:Farbe=Qt::magenta;break;
    case 5:Farbe.setRgb(57,255,239);
    default:
    {
        Farbe=Qt::green;//Setzt bei nicht aufgeführten werten alles zurück.
        nextColorint=-1;
    }
    }
    return Farbe;
}
  QWidget* CartoonEngine::settingsWidget()
  {
    if (!m_settingsWidget) {
      m_settingsWidget = new CartoonSettingsWidget;

      // connect the signals
      connect(m_settingsWidget, SIGNAL(destroyed()), this, SLOT(settingsWidgetDestroyed()));
      connect(m_settingsWidget->aHelixSpin, SIGNAL(valueChanged(double)), this, SLOT(setHelixA(double)));
      connect(m_settingsWidget->bHelixSpin, SIGNAL(valueChanged(double)), this, SLOT(setHelixB(double)));
      connect(m_settingsWidget->cHelixSpin, SIGNAL(valueChanged(double)), this, SLOT(setHelixC(double)));
      
      connect(m_settingsWidget->aSheetSpin, SIGNAL(valueChanged(double)), this, SLOT(setSheetA(double)));
      connect(m_settingsWidget->bSheetSpin, SIGNAL(valueChanged(double)), this, SLOT(setSheetB(double)));
      connect(m_settingsWidget->cSheetSpin, SIGNAL(valueChanged(double)), this, SLOT(setSheetC(double)));

      connect(m_settingsWidget->aLoopSpin, SIGNAL(valueChanged(double)), this, SLOT(setLoopA(double)));
      connect(m_settingsWidget->bLoopSpin, SIGNAL(valueChanged(double)), this, SLOT(setLoopB(double)));
      connect(m_settingsWidget->cLoopSpin, SIGNAL(valueChanged(double)), this, SLOT(setLoopC(double)));
      
      connect(m_settingsWidget->helixColorButton, SIGNAL(colorChanged(QColor)), this, SLOT(setHelixColor(QColor)));
      connect(m_settingsWidget->sheetColorButton, SIGNAL(colorChanged(QColor)), this, SLOT(setSheetColor(QColor)));
      connect(m_settingsWidget->loopColorButton, SIGNAL(colorChanged(QColor)), this, SLOT(setLoopColor(QColor)));

      // set the parameters
      m_settingsWidget->aHelixSpin->setValue(m_aHelix);
      m_settingsWidget->bHelixSpin->setValue(m_bHelix);
      m_settingsWidget->cHelixSpin->setValue(m_cHelix);
      m_settingsWidget->aSheetSpin->setValue(m_aSheet);
      m_settingsWidget->bSheetSpin->setValue(m_bSheet);
      m_settingsWidget->cSheetSpin->setValue(m_cSheet);
      m_settingsWidget->aLoopSpin->setValue(m_aLoop);
      m_settingsWidget->bLoopSpin->setValue(m_bLoop);
      m_settingsWidget->cLoopSpin->setValue(m_cLoop);

      // set the colors
      QColor color;
      color.setRgb(m_helixColor.red(), m_helixColor.green(), m_helixColor.blue());
      m_settingsWidget->helixColorButton->setColor(color);
      color.setRgb(m_sheetColor.red(), m_sheetColor.green(), m_sheetColor.blue());
      m_settingsWidget->sheetColorButton->setColor(color);
      color.setRgb(m_loopColor.red(), m_loopColor.green(), m_loopColor.blue());
      m_settingsWidget->loopColorButton->setColor(color);
    }
void FilterButton::paintEvent(QPaintEvent *e){
    QPainter p(this);
    p.setRenderHint(p.Antialiasing);
    QColor fg;
    if (this->isChecked()){
        QColor c1,c2;
        QLinearGradient lg1(0,0,0,this->height());
        c1.setRgb(54,102,164);
        c2.setRgb(102,157,206);
        p.setPen(c1);
        lg1.setColorAt(0,c2);
        lg1.setColorAt(1,c1);
        p.setBrush(lg1);
        p.drawRect(0,0,this->width(),this->height());
        fg.setRgb(255,255,255);
    }
    else fg.setRgb(60,60,60);
/*    QPen p1;
    p1.setColor(fg);
    p1.setWidth(4);
    p1.setCapStyle(Qt::RoundCap);
    p.setBrush(Qt::transparent);
    p.setPen(p1);*/
    int xc,yc;
    xc=this->width()/2;
    yc=this->height()/2;

    QPolygon pol(6);
    pol.setPoint(0,xc-8,yc-6);
    pol.setPoint(1,xc+8,yc-6);
    pol.setPoint(2,xc+2,yc+2);
    pol.setPoint(3,xc+2,yc+7);
    pol.setPoint(4,xc-2,yc+7);
    pol.setPoint(5,xc-2,yc+2);

    p.setBrush(fg);
    p.setPen(Qt::transparent);

    p.drawPolygon(pol);

    e->accept();
}
void vtkDataMeshInteractor::setColor(QColor color)
{
    if( ! color.isValid())
        color.setRgb(0,0,0);

    double r,g,b;
    color.getRgbF(&r, &g, &b);
    d->actorProperty->SetColor(r, g, b);

    d->render->Render();
}
Beispiel #28
0
QColor Cell::getQColor()
{
    QColor color;
    if(this->is_blank) { color.setRgb(100, 100, 100); }
    else{
        switch(this->color)
        {
        case BLACK: color.setRgb(255, 0, 0); break;
        case CYAN: color.setRgb(150, 200, 200); break;
        case YELLOW: color.setRgb(255, 200, 50); break;
        case MAGENTA: color.setRgb(120, 0, 120); break;
        case ORANGE: color.setRgb(255, 150, 50); break;
        case BLUE: color.setRgb(0, 130, 130); break;
        case GREEN: color.setRgb(60, 200, 60); break;
        case RED: color.setRgb(255, 60, 60); break;
        default: color.setRgb(255, 0, 0); break;
        }
    }
    return color;
}
void MainWindow::addCurve(QCustomPlot *customPlot,int i){

        QColor color;
        color.setRgb(rand()%255, rand()%255, rand()%255);
        customPlot->addGraph();
        customPlot->graph(i)->setPen(QPen(color));
        customPlot->graph(i)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));
        QString name = QString("DeviceID: %1").arg(dev_id[i]);
        customPlot->graph(i)->setName(name);

}
Beispiel #30
0
QColor Config::getColor(const QString& name)
{
	QColor color;

	QJsonArray jArr = findKey(name).toArray();

	if (jArr.size() == 3)
		color.setRgb(jArr.at(0).toInt(), jArr.at(1).toInt(), jArr.at(2).toInt());

	return color;
}