void ColorWheel::mouseMoveEvent(QMouseEvent* e) { lastPos_ = e->pos(); if (!mouseDown_) return; if (wheelRegion_.contains(lastPos_) && inWheel_) { QColor color = posColor(lastPos_); hueChanged(color.hue()); } else if (squareRegion_.contains(lastPos_) && inSquare_) { QColor color = posColor(lastPos_); svChanged(color); } else { int length = qMin(width(), height()); QPoint center(length/2, length/2); if (inWheel_) { int r = length / 2; double x0 = lastPos_.x()-center.x(); double y0 = lastPos_.y()-center.y(); double vNorm = qSqrt(qPow(x0,2)+qPow(y0,2)); double x1 = r*(x0/vNorm); double y1 = r*(y0/vNorm); x1 += center.x(); y1 += center.y(); QColor color = posColor(QPoint(x1, y1)); hueChanged(color.hue()); } else if (inSquare_) { int w = qMin(width(), height()); // radius of outer circle qreal r = w/2-margin_; // radius of inner circle qreal ir = r-wheelWidth_; // left corner of square qreal m = w/2.0-ir/qSqrt(2); float x0 = 0.0f; float y0 = 0.0f; float w0 = squareRegion_.boundingRect().width(); if (lastPos_.x() > m + w0) x0 = m + w0; else if (lastPos_.x() < m) x0 = m; else x0 = lastPos_.x(); if (lastPos_.y() > m + w0) y0 = m + w0; else if (lastPos_.y() < m) y0 = m; else y0 = lastPos_.y(); QColor color = posColor(QPoint(x0, y0)); svChanged(color); } } }
void NQColorWheel::mouseMoveEvent(QMouseEvent *event) { lastPosition_ = event->pos(); if (!mousePressed_) return; if (insideWheel_) { QColor color = colorFromPosition(lastPosition_); if (color.isValid()) hueChanged(color.hue()); } else if (insideSquare_){ QColor color = colorFromPosition(lastPosition_); if (color.isValid()) svChanged(color); } else { // TODO: due with cursor out of region after press // int length = qMin(width(), height()); // QPoint center(length/2, length/2); // int R = qSqrt(qPow(qAbs(lastPos.x()), 2) // + qPow(qAbs(lastPos.y()), 2)); // if(inWheel){ // int r = length / 2; // r += qSqrt(qPow(center.x(), 2) + qPow(center.y(), 2)); // int x0 = r/R * qAbs(lastPos.x()); // int y0 = r/R * qAbs(lastPos.y()); // QColor color = posColor(QPoint(x0, y0)); // hueChanged(color.hue()); // }else if(inSquare){ // // // } } }
void ColorWheel::mouseMoveEvent(QMouseEvent *event) { lastPos = event->pos(); if( !mouseDown ) return; if(wheelRegion.contains(lastPos) && inWheel){ QColor color = posColor(lastPos); hueChanged(color.hue()); }else if(squareRegion.contains(lastPos) && inSquare){ QColor color = posColor(lastPos); svChanged(color); }else{ // TODO: due with cursor out of region after press // int length = qMin(width(), height()); // QPoint center(length/2, length/2); // int R = qSqrt(qPow(qAbs(lastPos.x()), 2) // + qPow(qAbs(lastPos.y()), 2)); // if(inWheel){ // int r = length / 2; // r += qSqrt(qPow(center.x(), 2) + qPow(center.y(), 2)); // int x0 = r/R * qAbs(lastPos.x()); // int y0 = r/R * qAbs(lastPos.y()); // QColor color = posColor(QPoint(x0, y0)); // hueChanged(color.hue()); // }else if(inSquare){ // // // } } }
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); }
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); }
void ColorWheel::mousePressEvent(QMouseEvent *event) { lastPos = event->pos(); if(wheelRegion.contains(lastPos)){ inWheel = true; inSquare = false; QColor color = posColor(lastPos); hueChanged(color.hue()); }else if(squareRegion.contains(lastPos)){ inWheel = false; inSquare = true; QColor color = posColor(lastPos); svChanged(color); } mouseDown = true; }
void ColorWheel::mousePressEvent(QMouseEvent *event) { QPoint lastPos = event->pos(); if (m_squareRegion.contains(lastPos)) { m_isInWheel = false; m_isInSquare = true; QColor color = pickColor(lastPos); svChanged(color); } else if (m_wheelRegion.contains(lastPos)) { m_isInWheel = true; m_isInSquare = false; QColor color = pickColor(lastPos); hueChanged(color.hue()); } }
void NQColorWheel::mousePressEvent(QMouseEvent *event) { lastPosition_ = event->pos(); if (regionWheel_.contains(lastPosition_)) { insideWheel_ = true; insideSquare_ = false; QColor color = colorFromPosition(lastPosition_); hueChanged(color.hue()); } else if (regionSquare_.contains(lastPosition_)) { insideWheel_ = false; insideSquare_ = true; QColor color = colorFromPosition(lastPosition_); svChanged(color); } mousePressed_ = true; }
void ColorWheel::changeColor(const QColor &color) { if (color == m_currentColor) { return; } if (color.hue() != m_currentColor.hue()) { hueChanged(color.hue()); } if (color.saturation() != m_currentColor.saturation() || color.value() != m_currentColor.value() ) { svChanged(color); } //emit colorChanged(color); update(); }
void ColorWheel::mousePressEvent(QMouseEvent* e) { lastPos_ = e->pos(); if (wheelRegion_.contains(lastPos_)) { inWheel_ = true; inSquare_ = false; QColor color = posColor(lastPos_); if (e->button()==Qt::RightButton) hueChanged(color.hue()); else setColor(color); } else if (squareRegion_.contains(lastPos_)) { inWheel_ = false; inSquare_ = true; QColor color = posColor(lastPos_); svChanged(color); } mouseDown_ = true; }
void ColorWheel::setColor(const QColor &color) { if (color == m_currentColor) { return; } if (color.hue() != m_currentColor.hue()) { hueChanged(color.hue()); } if (color.saturation() != m_currentColor.saturation() || color.value() != m_currentColor.value() ) { svChanged(color); } update(); emit colorSelected(color); }
void ColorWheel::mouseMoveEvent(QMouseEvent* event) { QPoint lastPos = event->pos(); if ( event->buttons() == Qt::NoButton ) { return; } if (m_isInSquare) { QRect rect = m_squareRegion.boundingRect(); if ( lastPos.x() < rect.topLeft().x() ) { lastPos.setX( rect.topLeft().x() ); } else if ( lastPos.x() > rect.bottomRight().x() ) { lastPos.setX( rect.bottomRight().x() ); } if ( lastPos.y() < rect.topLeft().y() ) { lastPos.setY( rect.topLeft().y() ); } else if ( lastPos.y() > rect.bottomRight().y() ) { lastPos.setY( rect.bottomRight().y() ); } QColor color = pickColor(lastPos); svChanged(color); } else if (m_wheelRegion.contains(lastPos) && m_isInWheel) { QColor color = pickColor(lastPos); hueChanged(color.hue()); } }
//Save new set value void Regulator::setSv(double newValue) { sv = newValue; emit svChanged( QString::number( newValue, 'f', 2 ) + QString::fromUtf8( "\u00B0" ) ); }