Ejemplo n.º 1
0
      void BackgroundRgbProvider::setBackgroundColor(pqRenderView* view, bool useCurrentBackgroundColor)
      {
        std::vector<double> backgroundRgb = getRgb(useCurrentBackgroundColor);

        vtkSMDoubleVectorProperty* background = vtkSMDoubleVectorProperty::SafeDownCast(view->getViewProxy()->GetProperty("Background"));

        background->SetElements3(backgroundRgb[0],backgroundRgb[1],backgroundRgb[2]);

        view->resetCamera();
      }
Ejemplo n.º 2
0
void LCD_GradientFill(u16 x0, u16 y0, u16 x1, u16 y1, u8 PercentageFilled, const u16 *GradientStops, u8 GradientStopsCount)
{
    if (y1 > y0 || PercentageFilled > 100) return;
    u16 i;
    u16 DeltaY = y0 - y1;
    u16 StopY = y0 - ((PercentageFilled*DeltaY)/100);

    for (i = 0; i < DeltaY; i++) {
        if (y0 == StopY) break;
        LCD_Line(x0, y0, x1, y0, getRgb(0, DeltaY, i, GradientStops, GradientStopsCount));
        y0--;
    }

}
Ejemplo n.º 3
0
RecSkinWidget::RecSkinWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::RecSkinWidget)
    , nowPixNum(-1)
    , m_rowMaxPix(15)
{
    ui->setupUi(this);
    setFixedSize(490,255);

    QStringList l = MOption::instance()->option(OPTION_Recommand, OPTION_GROUP_Theme).toStringList();
    QString appPath = QCoreApplication::applicationDirPath() + "/";

    for(int i = 0; i < 4; ++i)
    {
        RecSkinPushButton *SkinPushButton = new RecSkinPushButton(this);
        connect(SkinPushButton,SIGNAL(currentPixmap(QString,QPixmap,QColor)),
                this,SIGNAL(currentPixmap(QString,QPixmap,QColor)));

        connect(SkinPushButton,SIGNAL(clickNum(int)),
                this,SLOT(onClickNum(int)));
        if(i <= l.size() - 1)
        {
            QString path = appPath + l.at(i);
            qDebug() << path;
            QPixmap pix(path);
            SkinPushButton->setToolTip("");
            if(i == 0)
            {
                QString themeType = MOption::instance()->option("WindowBGPixmapType", "theme").toString();


                QImage skinImage(pix.toImage());
                int num = 0;
                int red = 0;
                int green = 0;
                int blue = 0;
                for(int ii = 0; ii < skinImage.width(); ++ii)
                {
                    for(int j = 0; j < skinImage.height(); ++j)
                    {
                        ++num;
                        QRgb rgbValue(skinImage.pixel(ii, j));
                        red += qRed(rgbValue);
                        green += qGreen(rgbValue);
                        blue += qBlue(rgbValue);
                    }
                }
                if(num != 0)
                {
                    red = red/num;
                    green = green/num;
                    blue = blue/num;
                }

                oneFileName = path;
                onePix = pix;
                oneColor = QColor(red,green,blue,255);
                if(themeType.isEmpty())
                {
                    SkinPushButton->setPixmap(path,pix,oneColor,120,true);

                    QTimer::singleShot(1000, this, SLOT(getRgb()));
                }
                else
                {
                    SkinPushButton->setPixmap(path,pix,QColor(255,255,255,255),120);
                }
            }
            else
            {
                SkinPushButton->setPixmap(path,pix,QColor(255,255,255,255),120);
            }
            SkinPushButton->setSkin(true);
        }


        ui->horizontalLayoutDefault->addWidget(SkinPushButton);
    }

    QPixmap addPix(":/add.png");
    QPixmap historyPix(":/skinHistoryImage.png");
    RecSkinPushButton *button = new RecSkinPushButton(this);
    button->setPixmap("",addPix, QColor(255,255,255,255),60,false);
    connect(button,SIGNAL(clickResult()),
            this,SIGNAL(definePixmapResult()));
    ui->horizontalLayoutHistoryBotton->insertWidget(0,button);


    QString historyPath = QCoreApplication::applicationDirPath() + "/theme/saved";

    // TODO MEM leak
    QDir *dir = new QDir(historyPath);
    QStringList filter;

    QList<QFileInfo> *fileInfo=new QList<QFileInfo>(dir->entryInfoList(filter));

    QStringList fileNames;

    for(int i = 0; i < fileInfo->count(); ++ i)
    {
        if(fileInfo->at(i).isDir())
            continue;
        fileNames << fileInfo->at(i).fileName();
    }
    fileNames.sort();
    int fileSize = fileNames.size();
    if(fileSize > m_rowMaxPix)
        fileSize = m_rowMaxPix;

    for(int i = 0; i < m_rowMaxPix - fileSize; ++i)
    {
        addItem("",historyPix, QColor(255,255,255,255),false,false);
    }

    for(int i = 0; i < fileSize; ++i)
    {
        QString imagePathName = historyPath + "/" + fileNames.value(i);
        QPixmap pxi(imagePathName);
        addItem(imagePathName,pxi, QColor(255,255,255,255),false,true);
    }

    QString themeType = MOption::instance()->option("WindowBGPixmapType", "theme").toString();
    if(themeType == "bitmap")
    {
        QString fileName = MOption::instance()->option("WindowBGPixmap", "theme").toString();

        for(int i = 0; i < buttons.size(); ++i)
        {
            if(buttons.value(i)->getFileName() == fileName)
                nowPixNum = i;
        }
    }
}
Ejemplo n.º 4
0
TPixel32 TColorValue::getPixel() const
{
	int r, g, b;
	getRgb(r, g, b);
	return TPixel32(r, g, b, (int)(m_m * 255.0 + 0.5));
}
Ejemplo n.º 5
0
void ColorListWidget::updateRow(int row)
{
	react_to_changes = false;
	
	const auto color = map->getColor(row);
	auto color_with_opacity = colorWithOpacity(*color);
	
	// Color preview
	auto item = color_table->item(row, 0);
	item->setBackground(color_with_opacity);
	
	// Name
	item = color_table->item(row, 1);
	item->setText(map->translate(color->getName()));
	
	// Spot color
	item = color_table->item(row, 2);
	item->setText(color->getSpotColorName());
	switch (color->getSpotColorMethod())
	{
		case MapColor::SpotColor:
			item->setData(Qt::DecorationRole, color_with_opacity);
			break;
		default:
			item->setData(Qt::DecorationRole, QColor(Qt::transparent));
	}
	
	// CMYK
	item = color_table->item(row, 3);
	item->setToolTip(tr("Double click to define the color"));
	const MapColorCmyk& cmyk = color->getCmyk();
	QLocale l;
	item->setText(QString::fromLatin1("%1/%2/%3/%4").arg(
	                l.toString(100*cmyk.c, 'g', 3), l.toString(100*cmyk.m, 'g', 3),
	                l.toString(100*cmyk.y, 'g', 3), l.toString(100*cmyk.k, 'g', 3)));
	switch (color->getCmykColorMethod())
	{
		case MapColor::SpotColor:
		case MapColor::RgbColor:
			item->setForeground(palette().color(QPalette::Disabled, QPalette::Text));
			item->setData(Qt::DecorationRole, QColor(Qt::transparent));
			break;
		default:
			item->setForeground(palette().color(QPalette::Active, QPalette::Text));
			item->setData(Qt::DecorationRole, colorWithOpacity(color->getCmyk(), color->getOpacity()));
	}
	
	// RGB
	item = color_table->item(row, 4);
	item->setText(QColor(color->getRgb()).name());
	item->setToolTip(item->text());
	switch (color->getRgbColorMethod())
	{
		case MapColor::SpotColor:
		case MapColor::CmykColor:
			item->setForeground(palette().color(QPalette::Disabled, QPalette::Text));
			item->setData(Qt::DecorationRole, QColor(Qt::transparent));
			break;
		default:
			item->setForeground(palette().color(QPalette::Active, QPalette::Text));
			item->setData(Qt::DecorationRole, colorWithOpacity(color->getRgb(), color->getOpacity()));
	}
	
	// Knockout
	item = color_table->item(row, 5);
	item->setCheckState(color->getKnockout() ? Qt::Checked : Qt::Unchecked);
	item->setForeground(palette().color(QPalette::Disabled, QPalette::Text));
	
	// Opacity
	item = color_table->item(row, 6);
	item->setData(Qt::DisplayRole, color->getOpacity());
	
	react_to_changes = true;
}