Пример #1
0
ColorBox::ColorBox(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ColorBox)
{
    ui->setupUi(this);
    connect(ui->colorWheel,SIGNAL(colorChange(QColor)),
            this,SLOT(onWheelChange(QColor)));
    connect(ui->colorSpinBoxGroup,SIGNAL(colorChange(QColor)),
            this,SLOT(onSpinboxChange(QColor)));
}
Пример #2
0
dockListUpdate mutableSquareImageContainer::replaceRareColors() {

  QHash<QRgb, int> countHash;
  ::colorCounts(image_, originalDimension_, &countHash);

  rareColorsDialog countDialog(countHash);
  const int dialogReturnCode = countDialog.exec();
  QList<QRgbPair> pairs = countDialog.colorsToChange();
  if (dialogReturnCode == QDialog::Accepted && pairs.size() > 0) {
    QList<colorChange> changeHistories;
    QSet<flossColor> oldFloss;
    QVector<triC> oldColors;
    for (int i = 0, size = pairs.size(); i < size; ++i) {
      const QRgb oldColor = pairs[i].first;
      const triC oldTriColor(oldColor);
      oldColors.push_back(oldTriColor);
      oldFloss.insert(getFlossColorFromColor(oldTriColor));
      const QRgb newColor = pairs[i].second;
      const QVector<pairOfInts> changedSquares =
        ::changeColor(&image_, oldColor, newColor, originalDimension_);
      if (!changedSquares.empty()) {
        removeColor(oldColor);
        changeHistories.push_back(colorChange(oldColor, newColor,
                                              changedSquares));
      }
    }
    addToHistory(historyItemPtr(new rareColorsHistoryItem(changeHistories,
                                                          oldFloss)));
    return dockListUpdate(oldColors, true);
  }
  else {
    return dockListUpdate();
  }
}
void ColorSpinBoxGroup::onColorChanged()
{
    // TODO:
    if(noColorUpdate) return;

    QColor c;
    if(isRgbColors){
        c = QColor::fromRgb(ui->RedspinBox->value(),
                            ui->GreenspinBox->value(),
                            ui->BluespinBox->value());
    }else{
        c = QColor::fromHsvF(qBound(0.0,
                                    ui->RedspinBox->value()/359.0,
                                    1.0),
                             qBound(0.0,
                                    ui->GreenspinBox->value()/100.0,
                                    1.0),
                             qBound(0.0,
                                    ui->BluespinBox->value()/100.0,
                                    1.0));
    }

    color_ = c;
    emit colorChange(c);
}
Пример #4
0
void ColorWheel::onSVChanged(const QColor &newcolor)
{
    int hue = start.hue();
    start.setHsv(hue, newcolor.saturation(),
                   newcolor.value());
    if(!isVisible()) return;
    repaint();
    emit colorChange(start);
}
Пример #5
0
void ColorWheel::svChanged(const QColor& newcolor) {
    int hue = currentColor_.hue();
    currentColor_.setHsv(hue, newcolor.saturation(),
                   newcolor.value());

    if (!isVisible()) return;

    repaint();
    emit colorChange(currentColor_);
}
Пример #6
0
void ColorWheel::onHueChanged(const int &hue)
{
    if( hue<0 ||hue>359)return;
    int s = start.saturation();
    int v = start.value();
    start.setHsv(hue, s, v);
    if(!isVisible()) return;
    //drawSquareImage(hue);
    repaint();
    emit colorChange(start);
}
Пример #7
0
void ColorWheel::svChanged(const QColor &newcolor)
{
    int hue = current.hue();
    current.setHsv(hue, newcolor.saturation(), newcolor.value());
    if(!isVisible()) return;
    drawWheel(size());
    drawSquare(hue);
    drawIndicator(hue);
    drawPicker(newcolor);
    repaint();
    emit colorChange(current);
}
Пример #8
0
void ColorWheel::setColor(const QColor& color) {
    if (color == currentColor_) return;

    if (color.hue() != currentColor_.hue())
        hueChanged(color.hue());

    if (color.saturation() != currentColor_.saturation()
        || color.value() != currentColor_.value())
        svChanged(color);

    update();
    emit colorChange(color);
}
Пример #9
0
void ColorWheel::hueChanged(const int& hue) {
    if (hue < 0 || hue > 359) return;

    int s = currentColor_.saturation();
    int v = currentColor_.value();
    currentColor_.setHsv(hue, s, v);
    updateSquareImage(hue);

    if (!isVisible()) return;

    repaint();
    emit colorChange(currentColor_);
}
Пример #10
0
void ColorSpinBoxGroup::onOpacityChanged()
{
    if(noColorUpdate) return;

    color_.setAlphaF(qBound(0.0,
                            ui->opacityBox->value()/100.0,
                            1.0));
    QPalette p = ui->label->palette();
    p.setColor(QPalette::Background, color_);
    ui->label->setPalette(p);
    emit opacityChange(ui->opacityBox->value());
    emit colorChange(color_);
}
Пример #11
0
void ColorWheel::hueChanged(const int &hue)
{
    if( hue<0 ||hue>359)return;
    int s = current.saturation();
    int v = current.value();
    current.setHsv(hue, s, v);
    if(!isVisible()) return;
    drawWheel(size());
    drawSquare(hue);
    drawIndicator(hue);
    drawPicker(current);
    repaint();
    emit colorChange(current);
}
Пример #12
0
void NQColorWheel::hueChanged(int hue)
{
    if (hue<0 || hue>359) return;
    int s = currentColor_.saturation();
    int v = currentColor_.value();
    currentColor_.setHsv(hue, s, v);
    if (!isVisible()) return;
    //drawWheel(size());
    initializeSquare(hue);
    //drawIndicator(hue);
    //drawPicker(current);
    repaint();
    emit colorChange(currentColor_);
}
Пример #13
0
void ColorWheel::setColor(const QColor &color)
{
    if(color == start) return;
    if(color.hue() != start.hue()){
        onHueChanged(color.hue());
    }

    if( color.saturation() != start.saturation()
            || color.value() != start.value() ){
        onSVChanged(color);
    }

    update();
    emit colorChange(color);
}
Пример #14
0
void ColorWheel::setColor(const QColor &color)
{
    if(color == current) return;
    if(color.hue() != current.hue()){
        hueChanged(color.hue());
    }

    if( color.saturation() != current.saturation()
            || color.value() != current.value() ){
        svChanged(color);
    }

    update();
    emit colorChange(color);
}
Пример #15
0
NQColorWheel::NQColorWheel(QWidget *parent) :
    QWidget(parent),
    size_(200, 200),
    margin_(5),
    wheelWidth_(20),
    minimumS_(0.0),
    currentColor_(Qt::white),
    mousePressed_(false),
    insideWheel_(false),
    insideSquare_(false)
{
    setFixedSize(size_);

    currentColor_ = currentColor_.toHsv();

    emit colorChange(currentColor_);
}
Пример #16
0
//-------------------------------------------------------------
void Polaroidframe::update(){
    
    animation();
    transition();
    colorChange();
    h = w*scale;
    
    if (bFrame) {
        offSet = w/15;
        imgW = w - offSet*2;
        imgH = h - offSet*2;
    }else{
        imgW = w;
        imgH = h;
    }
    
    if (bBottomBanner) {
        fontScale = ofMap(w, 0, 300, 0, 0.30);
        h = h*1.20;
    }
    
}
Пример #17
0
void MainWindow::ServerOperations(QByteArray data)
{
    QString Line(data);
    QStringList dataList = Line.split(" ");
    bool tf=false;
    QTcpSocket* clientTcpSocket = (QTcpSocket*)sender();
    for (int i=0;i<Commands.size();i++)
        if (dataList[0] == Commands[i]) tf=true;
    if (!tf) {
        messageTo = "FAILED\n";
        sendToClient(clientTcpSocket,messageTo);
        return;
    }
    QStringList typeCommand = dataList[0].split("-");
    if (typeCommand[0]=="set") {
        dataList[1].chop(1);
        if (typeCommand[2]=="state")        stateChange(dataList[1]);
        else if (typeCommand[2]=="color")   colorChange(dataList[1]);
        else if (typeCommand[2]=="rate")    rateChange(dataList[1]);
    } else  if (typeCommand[0]=="get") {
        typeCommand[2].chop(1);
        if (typeCommand[2]=="state") {
            messageTo = "OK " + state + "\n";
            sendToClient(clientTcpSocket,messageTo);
        } else if (typeCommand[2]=="color") {
            messageTo = "OK " + color.name() + "\n";
            sendToClient(clientTcpSocket,messageTo);
        } else if (typeCommand[2]=="rate") {
            messageTo = "OK " + QString::number(rate) + "\n";
            sendToClient(clientTcpSocket,messageTo);
        } else {
            messageTo = "FAILED\n";
            sendToClient(clientTcpSocket,messageTo);
        }
    }
}
void TransferFunctionPropertyDialog::generateWidget() {
    vec2 minEditorDims = vec2(255.0f, 100.0f);

    tfEditorView_ = new TransferFunctionEditorView(tfProperty_);
    tfProperty_->get().addObserver(tfEditorView_);
    // put origin to bottom left corner
    tfEditorView_->scale(1.0, -1.0);
    tfEditorView_->setAlignment(Qt::AlignLeft | Qt::AlignBottom);
    tfEditorView_->setMinimumSize(minEditorDims.x, minEditorDims.y);
    tfEditorView_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    tfEditorView_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    
    tfEditor_ = new TransferFunctionEditor(&tfProperty_->get(), tfEditorView_);
    connect(tfEditor_, SIGNAL(doubleClick()), this, SLOT(showColorDialog()));
    connect(tfEditor_, SIGNAL(selectionChanged()), this, SLOT(updateColorWheel()));
    tfEditorView_->setScene(tfEditor_);

    zoomVSlider_ = new RangeSliderQt(Qt::Vertical, this);
    zoomVSlider_->setRange(0, sliderRange_);
    zoomVSlider_->setMinSeparation(5);
    // flip slider values to compensate for vertical slider layout
    zoomVSlider_->setValue(sliderRange_ - static_cast<int>(tfProperty_->getZoomV().y*sliderRange_),
                           sliderRange_ - static_cast<int>(tfProperty_->getZoomV().x*sliderRange_));
    connect(zoomVSlider_, SIGNAL(valuesChanged(int, int)),
            this, SLOT(changeVerticalZoom(int, int)));
    
    zoomHSlider_ = new RangeSliderQt(Qt::Horizontal, this);
    zoomHSlider_->setRange(0, sliderRange_);
    zoomHSlider_->setMinSeparation(5);
    zoomHSlider_->setValue(static_cast<int>(tfProperty_->getZoomH().x*sliderRange_),
                           static_cast<int>(tfProperty_->getZoomH().y*sliderRange_));
    connect(zoomHSlider_, SIGNAL(valuesChanged(int, int)),
            this, SLOT(changeHorizontalZoom(int, int)));

    maskSlider_ = new RangeSliderQt(Qt::Horizontal, this);
    maskSlider_->setRange(0, sliderRange_);
    maskSlider_->setValue(static_cast<int>(tfProperty_->getMask().x*sliderRange_),
                          static_cast<int>(tfProperty_->getMask().y*sliderRange_));
    connect(maskSlider_, SIGNAL(valuesChanged(int, int)),
            this, SLOT(changeMask(int, int)));
    
    colorWheel_ = new ColorWheel();
    connect(colorWheel_, SIGNAL(colorChange(QColor)), this, SLOT(setPointColor(QColor)));
    
    btnClearTF_ = new QPushButton("Reset");
    connect(btnClearTF_, SIGNAL(clicked()), tfEditor_, SLOT(resetTransferFunction()));
    btnClearTF_->setStyleSheet(QString("min-width: 30px; padding-left: 7px; padding-right: 7px;"));
    
    btnImportTF_ = new QPushButton("Import");
    connect(btnImportTF_, SIGNAL(clicked()), this, SLOT(importTransferFunction()));
    btnImportTF_->setStyleSheet(QString("min-width: 30px; padding-left: 7px; padding-right: 7px;"));
    
    btnExportTF_ = new QPushButton("Export");
    connect(btnExportTF_, SIGNAL(clicked()), this, SLOT(exportTransferFunction()));
    btnExportTF_->setStyleSheet(QString("min-width: 30px; padding-left: 7px; padding-right: 7px;"));

    tfPreview_ = new QLabel();
    tfPreview_->setMinimumSize(1,20);
    QSizePolicy sliderPol = tfPreview_->sizePolicy();
    sliderPol.setHorizontalStretch(3);
    tfPreview_->setSizePolicy(sliderPol);
    
    cmbInterpolation_ = new QComboBox();
    cmbInterpolation_->addItem("Interpolation: Linear");
    //cmbInterpolation_->addItem("Interpolation: Cubic"); // Not implemented... (yet)
    cmbInterpolation_->setCurrentIndex(tfProperty_->get().getInterpolationType());
    connect(cmbInterpolation_, SIGNAL(currentIndexChanged(int)),
            this, SLOT(switchInterpolationType(int)));
    
    chkShowHistogram_ = new QComboBox();
    chkShowHistogram_->addItem("Histogram: Off");
    chkShowHistogram_->addItem("Histogram: 100%");
    chkShowHistogram_->addItem("Histogram: 99%");
    chkShowHistogram_->addItem("Histogram: 95%");
    chkShowHistogram_->addItem("Histogram: 90%");
    chkShowHistogram_->addItem("Histogram: Log");
    chkShowHistogram_->setCurrentIndex(tfProperty_->getShowHistogram());
    connect(chkShowHistogram_, SIGNAL(currentIndexChanged(int)), this, SLOT(showHistogram(int)));
    
    pointMoveMode_ = new QComboBox();
    pointMoveMode_->addItem("Point Movement: Free");
    pointMoveMode_->addItem("Point Movement: Restrict");
    pointMoveMode_->addItem("Point Movement: Push");
    pointMoveMode_->setCurrentIndex(0);
    connect(pointMoveMode_, SIGNAL(currentIndexChanged(int)), this, SLOT(changeMoveMode(int)));

    colorDialog_ = new QColorDialog(this);
    colorDialog_->hide();
    colorDialog_->setOption(QColorDialog::ShowAlphaChannel, true);
    colorDialog_->setOption(QColorDialog::NoButtons, true);
    colorDialog_->setWindowModality(Qt::NonModal);
    colorDialog_->setWindowTitle(QString::fromStdString(tfProperty_->getDisplayName()));
    connect(colorDialog_, SIGNAL(currentColorChanged(QColor)),
            this, SLOT(setPointColorDialog(QColor)));
    
    QFrame* leftPanel = new QFrame(this);
    QGridLayout* leftLayout = new QGridLayout();
    leftLayout->setContentsMargins(0, 0, 0, 0);
    leftLayout->setSpacing(7);
    leftLayout->addWidget(zoomVSlider_,  0, 0);
    leftLayout->addWidget(tfEditorView_, 0, 1);
    leftLayout->addWidget(zoomHSlider_,  1, 1);
    leftLayout->addWidget(tfPreview_,    2, 1);
    leftLayout->addWidget(maskSlider_,   3, 1);
    leftPanel->setLayout(leftLayout);
    
    QFrame* rightPanel = new QFrame(this);
    QVBoxLayout* rightLayout = new QVBoxLayout();
    rightLayout->setContentsMargins(0, 0, 0, 0);
    rightLayout->setSpacing(7);
    rightLayout->setAlignment(Qt::AlignTop);
    rightLayout->addWidget(colorWheel_);
    rightLayout->addWidget(cmbInterpolation_);
    rightLayout->addWidget(chkShowHistogram_);
    rightLayout->addWidget(pointMoveMode_);
    rightLayout->addStretch(3);
    QHBoxLayout* rowLayout = new QHBoxLayout();
    rowLayout->addWidget(btnClearTF_);
    rowLayout->addWidget(btnImportTF_);
    rowLayout->addWidget(btnExportTF_);
    rightLayout->addLayout(rowLayout);


    rightPanel->setLayout(rightLayout);
    
    QWidget* mainPanel = new QWidget(this);
    QHBoxLayout* mainLayout = new QHBoxLayout();
    mainLayout->setContentsMargins(7, 7, 7, 7);
    mainLayout->setSpacing(7);
    mainLayout->addWidget(leftPanel);
    mainLayout->addWidget(rightPanel);
    mainPanel->setLayout(mainLayout);
    
    setWidget(mainPanel);
    connect(this, SIGNAL(dockLocationChanged(Qt::DockWidgetArea)),
            this, SLOT(dockLocationChanged(Qt::DockWidgetArea)));
    
    initialize(tfProperty_);
    setFloating(true);
    setVisible(false);
}
Пример #19
0
// メインプログラム
int main() {


	// アプリウインドウの準備
	AppEnv env(WIDTH, HEIGHT);

	//ランダムパターンが同じにならないように
	random.setSeed(u_int(time(nullptr)));

	//Object型のobjを作成
	enum {
		//enum で obj の最大値を設定
		//配列で作る場合:数を変えたいならこの数字を変えるだけ
		OBJ_MAX = 5
	};
	Object obj[OBJ_MAX];

	//初期化
	for (int i = 0; i < OBJ_MAX; ++i){
		obj[i] = {
			Vec2f(0, 0), Vec2f(50, 50),
			Vec2f(random.fromFirstToLast(-5, 5), random.fromFirstToLast(-5, 5)),
			random.fromZeroToOne(), random.fromZeroToOne(), random.fromZeroToOne()
		};
	}


	while (env.isOpen()){


		for (int i = 0; i < OBJ_MAX; ++i){
			//objに速度を加える
			//Vec2f + Vec2f が可能( (pos.x + speed.x), (pos.y + speed.y) )
			obj[i].pos += obj[i].speed;

			//壁とobjの当たり判定(当たったら反射)
			if (obj[i].pos.x() < -WIDTH / 2){						//左の壁
				obj[i].speed.x() = random.fromFirstToLast(2, 5);
				colorChange(obj[i].red, obj[i].green, obj[i].blue);
			}
			if (obj[i].pos.x() + obj[i].size.x() > WIDTH / 2){		//右の壁
				obj[i].speed.x() = random.fromFirstToLast(-5, -2);
				colorChange(obj[i].red, obj[i].green, obj[i].blue);
			}
			if (obj[i].pos.y() < -HEIGHT / 2){						//下の壁
				obj[i].speed.y() = random.fromFirstToLast(2, 5);
				colorChange(obj[i].red, obj[i].green, obj[i].blue);
			}
			if (obj[i].pos.y() + obj[i].size.y() > HEIGHT / 2){		//上の壁
				obj[i].speed.y() = random.fromFirstToLast(-5, -2);
				colorChange(obj[i].red, obj[i].green, obj[i].blue);
			}

		}


		// 描画準備
		env.setupDraw();



		//描画
		for (int i = 0; i < OBJ_MAX; ++i){
			drawFillBox(obj[i].pos.x(), obj[i].pos.y(),
				obj[i].size.x(), obj[i].size.y(), Color(obj[i].red, obj[i].green, obj[i].blue));
		}


		// 画面更新
		env.update();

	}

}
Пример #20
0
void ColorWheel::changeColor(const QColor &color)
{
    setColor(color);
    emit colorChange(color);
}
Пример #21
0
void ColorWheel::hueChanged(const int &hue)
{
    setColor(hue);
    emit colorChange(current);
}