Ejemplo n.º 1
0
void LabViewModule::parseGlobalcolor(QXmlStreamReader *xml)
{
    while(!(xml->tokenType() == QXmlStreamReader::EndElement && xml->name() == "globalcolor"))
    {
        if(xml->tokenType() == QXmlStreamReader::StartElement)
        {
            if(xml->name() == "red")
            {
                xml->readNext();
                currentColor()->setRed( xml->text().toString().toInt() );
            }
            if(xml->name() == "green")
            {
                xml->readNext();
                currentColor()->setGreen( xml->text().toString().toInt() );
            }
            if(xml->name() == "blu")
            {
                xml->readNext();
                currentColor()->setBlue( xml->text().toString().toInt() );
            }
            if(xml->name() == "intensity")
            {
                xml->readNext();
                currentColor()->setAlpha( xml->text().toString().toInt() );
            }
        }
        xml->readNext();
    }
    setGlobalColor(*currentColor());
    //sendGlobalColor(); // we update firmware data
}
Ejemplo n.º 2
0
QMenu* DragLabel::rightClickMenu()
{
  if (!m_RightClickMenu) {
    m_RightClickMenu = new QMenu(this);
    QMenu* colorMenu = new QMenu("Color", this);
    colorMenu->setIcon(QIcon(":/icons/color.svg"));
    QActionGroup* colorGroup = new QActionGroup(this);
    pRedColorAction = new QAction(QIcon(":/icons/red.svg"), tr("&Red"), this);
    pRedColorAction->setCheckable(true);
    if(currentColor()== Qt::red)
        pRedColorAction->setChecked(true);

    pOrangeColorAction = new QAction(QIcon(":/icons/orange.svg"), tr("&Orange"), this);
    pOrangeColorAction->setCheckable(true);
    if(currentColor() == QColor(254,154,46))
        pOrangeColorAction->setChecked(true);

    pGreenColorAction = new QAction(QIcon(":/icons/green.svg"), tr("&Green"), this);
    pGreenColorAction->setCheckable(true);
    if(currentColor()== Qt::green)
        pGreenColorAction->setChecked(true);

    pWhiteColorAction = new QAction(QIcon(":/icons/white.svg"), tr("&White"), this);
    pWhiteColorAction->setCheckable(true);
    if(currentColor()== Qt::white)
        pWhiteColorAction->setChecked(true);

    pGrayColorAction = new QAction(QIcon(":/icons/gray.svg"), tr("&Gray"), this);
    pGrayColorAction->setCheckable(true);
    if(currentColor()== Qt::lightGray)
        pGrayColorAction->setChecked(true);

    //group
    colorGroup->addAction(pRedColorAction);
    colorGroup->addAction(pOrangeColorAction);
    colorGroup->addAction(pGreenColorAction);
    colorGroup->addAction(pWhiteColorAction);
    colorGroup->addAction(pGrayColorAction);
    colorGroup->setExclusive(true);
    connect(colorGroup,SIGNAL(triggered(QAction *)),this,SLOT(changeColorSlot(QAction*)));

    //menu
    colorMenu->addAction(pRedColorAction);
    colorMenu->addAction(pOrangeColorAction);
    colorMenu->addAction(pGreenColorAction);
    colorMenu->addSeparator();
    colorMenu->addAction(pWhiteColorAction);
    colorMenu->addAction(pGrayColorAction);

    QAction* pDeleteAction = new QAction(QIcon(":/icons/delete.svg"), tr("&Delete"), this);
    connect(pDeleteAction,SIGNAL(triggered()),this,SLOT(deleteItemSlot()));


    m_RightClickMenu->addMenu(colorMenu);
    m_RightClickMenu->addAction(pDeleteAction);
  }
Ejemplo n.º 3
0
void PaletteEditor::drawPreviewGraphic(Graphic& dst) {
  colorPreview_.setColor(
    Color(currentColor().realR(),
          currentColor().realG(),
          currentColor().realB(),
          Color::fullAlphaOpacity));
  colorPreview_.render(dst,
                       Box(0, 0, dst.w(), dst.h()),
                       1.00);
}
Ejemplo n.º 4
0
void Ball::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    QRectF rect = boundingRect();
    QPen pen(currentColor());
    QBrush brush(currentColor());

    painter->setPen(pen);
    painter->setBrush(brush);
    painter->drawEllipse(rect);
}
void UIPopupPane::paintFrame(QPainter &painter)
{
    /* Paint frame: */
    QColor currentColor(palette().color(QPalette::Window).darker(150));
    QPainterPath path = painter.clipPath();
    painter.setClipping(false);
    painter.strokePath(path, currentColor);
}
Ejemplo n.º 6
0
void DragLabel::changeColor(const QColor &acolor)
{
    if(currentColor() !=  acolor ) {
        QPalette pal = palette();
        pal.setColor(backgroundRole(), acolor);
        setPalette(pal);
        emit colorChangedSignal();
    }
}
void ParticleEngine::createParticle( Particle * p )
{
	p->position = vec3( 0.0f, 0.0f, 0.0f );
	p->velocity = currentVelocity( ) - vec3( 0.3f * randomFloat( ) - 0.15f,
											 0.3f * randomFloat( ) - 0.15f,
											 0.3f * randomFloat( ) - 0.15f );
	p->color = currentColor( );
	p->timeAlive = 0;
	p->lifespan = randomFloat( ) + 1;
}
void UIPopupPane::paintBackground(const QRect &rect, QPainter &painter)
{
    /* Paint background: */
    QColor currentColor(palette().color(QPalette::Window));
    QColor newColor1(currentColor.red(), currentColor.green(), currentColor.blue(), opacity());
    QColor newColor2 = newColor1.darker(115);
    QLinearGradient headerGradient(rect.topLeft(), rect.bottomLeft());
    headerGradient.setColorAt(0, newColor1);
    headerGradient.setColorAt(1, newColor2);
    painter.fillRect(rect, headerGradient);
}
Ejemplo n.º 9
0
void RecSkinColorBrightnessRange::mousePressEvent(QMouseEvent *e)
{
    isDrawEllipse = true;
    if(e->x() > 0 && e->x() < this->width() && e->y() < 255 && e->y() > 0)
    {
        QRgb rgb = drawImage.scaled(this->width(),this->height()).pixel(e->x(),e->y());
        emit currentColor(QColor::fromRgb(rgb));
        emit sigMousePressSize(qAbs(e->y() - 255));
        mousePoint = e->pos();
        update();
    }
    isMousePress = true;
}
Ejemplo n.º 10
0
	void
	mousePressEvent(QMouseEvent * event) override
	{
		if (mIsAdding && event->button() == Qt::LeftButton) {
			QRectF rect = this->mapToScene(QRect(event->pos(), QSize(100, 100))).boundingRect();
			auto editableRect = new SceneItemWithContextMenu<EditableRectangle>();
			editableRect->setColor(currentColor());
			editableRect->setBoundingRect(rect);
			editableRect->setColorSetup(this);
			this->scene()->addItem(editableRect);
		} else {
			TGraphicsView::mousePressEvent(event);
		}
	}
Ejemplo n.º 11
0
void QgsDxfPaintEngine::drawLines( const QLineF* lines, int lineCount )
{
  if ( !mDxf || !mPaintDevice || !lines )
  {
    return;
  }

  for ( int i = 0; i < lineCount; ++i )
  {
    QgsPoint pt1 = toDxfCoordinates( lines[i].p1() );
    QgsPoint pt2 = toDxfCoordinates( lines[i].p2() );
    mDxf->writeLine( pt1, pt2, mLayer, "CONTINUOUS", currentColor(), currentWidth() );
  }
}
Ejemplo n.º 12
0
bool parseColorOrCurrentColor(RGBA32& parsedColor, const String& colorString, HTMLCanvasElement* canvas)
{
    ColorParseResult parseResult = parseColor(parsedColor, colorString);
    switch (parseResult) {
    case ParsedRGBA:
        return true;
    case ParsedCurrentColor:
        parsedColor = currentColor(canvas);
        return true;
    case ParseFailed:
        return false;
    default:
        ASSERT_NOT_REACHED();
        return false;
    }
}
Ejemplo n.º 13
0
void QgsDxfPaintEngine::drawPolygon( const QPointF* points, int pointCount, PolygonDrawMode mode )
{
  Q_UNUSED( mode );
  if ( !mDxf || !mPaintDevice )
  {
    return;
  }

  QgsPolyline polyline( pointCount );
  for ( int i = 0; i < pointCount; ++i )
  {
    polyline[i] = toDxfCoordinates( points[i] );
  }

  bool closed = ( pointCount > 3 && points[0] == points[pointCount - 1] );
  mDxf->writePolyline( polyline, mLayer, "CONTINUOUS", currentColor(), currentWidth(), closed );
}
Ejemplo n.º 14
0
void RecSkinColorPalette::mouseMoveEvent(QMouseEvent *e)
{
    if(isMousePress)
    {
        if(e->x() > 0
                && e->x() < this->width()
                && e->y() > 0
                && e->y() < this->height())
        {
            QRgb rgb = drawImage.scaled(this->width(),this->height()).pixel(e->x(),e->y());
            emit sigMousePressRGB(rgb);
            emit currentColor(QColor::fromRgb(rgb));
            mousePoint = e->pos();
            update();
        }
    }
}
Ejemplo n.º 15
0
void QgsDxfPaintEngine::drawRects( const QRectF* rects, int rectCount )
{
  if ( !mDxf || !mPaintDevice || !rects )
  {
    return;
  }

  for ( int i = 0; i < rectCount; ++i )
  {
    double left = rects[i].left();
    double right = rects[i].right();
    double top = rects[i].top();
    double bottom = rects[i].bottom();
    QgsPoint pt1 = toDxfCoordinates( QPointF( left, bottom ) );
    QgsPoint pt2 = toDxfCoordinates( QPointF( right, bottom ) );
    QgsPoint pt3 = toDxfCoordinates( QPointF( left, top ) );
    QgsPoint pt4 = toDxfCoordinates( QPointF( right, top ) );
    mDxf->writeSolid( mLayer, currentColor(), pt1, pt2, pt3, pt4 );
  }
}
Ejemplo n.º 16
0
void X_Drawer(int pnum)
{
#define XHAIR_LINE_WIDTH    1.f

    player_t* player = players + pnum;
    int xhair = MINMAX_OF(0, cfg.xhair, NUM_XHAIRS);
    float scale, oldLineWidth, color[4];
    Point2Rawf origin;
    RectRaw win;

    if(pnum < 0 || pnum >= MAXPLAYERS) return;

    // Is there a crosshair to draw?
    if(xhair == 0) return;

    color[CA] = currentOpacity(player);
    if(!(color[CA] > 0)) return;

    R_ViewWindowGeometry(pnum, &win);
    origin.x = win.origin.x + (win.size.width  / 2);
    origin.y = win.origin.y + (win.size.height / 2);
    scale = .125f + MINMAX_OF(0, cfg.xhairSize, 1) * .125f * win.size.height * ((float)80/SCREENHEIGHT);

    oldLineWidth = DGL_GetFloat(DGL_LINE_WIDTH);
    DGL_SetFloat(DGL_LINE_WIDTH, XHAIR_LINE_WIDTH);

    currentColor(player, color);
    DGL_Color4fv(color);

    GL_DrawSvg3(VG_XHAIR1 + (xhair-1), &origin, scale, MINMAX_OF(0.f, cfg.xhairAngle, 1.f) * 360);

    // Restore the previous state.
    DGL_SetFloat(DGL_LINE_WIDTH, oldLineWidth);

#undef XHAIR_LINE_WIDTH
}
Ejemplo n.º 17
0
void YviColorShower::showCurrentColor()
{
    m_colorLabel->setColor(currentColor());
    m_colorLabel->repaint();
}
Ejemplo n.º 18
0
	void ColorEdit::on_choose_clicked()
	{
		mColorDialog->setCurrentColor(currentColor());
		mColorDialog->open(this, SLOT(onColorSelected()));
	}
Ejemplo n.º 19
0
	void ColorEdit::on_choose_clicked()
	{
		mColorDialog->setCurrentColor(currentColor());
		mColorDialog->open(this, SLOT(onColorSelected()));
	}

	void ColorEdit::on_colorLineEdit_textChanged(const QString &text)
	{
		Q_UNUSED(text)

		if(ui->colorLineEdit->isCode())
			return;

		QPalette palette = ui->colorLineEdit->palette();
		QColor color = currentColor();

		palette.setColor(QPalette::Base, color);

		QColor inverseColor(255 - color.red(),
			255 - color.green(),
			255 - color.blue());

		palette.setColor(QPalette::Text, inverseColor);
		ui->colorLineEdit->setPalette(palette);
	}

	void ColorEdit::on_colorLineEdit_codeChanged(bool code)
	{
		if(code)
		{
Ejemplo n.º 20
0
void LabViewModule::parseMCode(QByteArray stream)
{
    QString str(stream);
    long value = SerialPort::embeddedstr2l( str, 0 );
    int idx = 0;
    int size = str.size();
    switch ( value )
    {
    case MCODE_LABVIEW_GET_GLOBAL_RGB:
    {
        SerialPort::nextField( str, idx);
        while ( idx < size )
        {
            if ( str[idx] == 'R' )
            {
                SerialPort::nextValue( str, idx);
                currentColor()->setRed( SerialPort::embeddedstr2l( str, idx ));
                setAllFacesColor( *currentColor() );
            }
            if ( str[idx] == 'E' )
            {
                SerialPort::nextValue( str, idx);
                currentColor()->setGreen( SerialPort::embeddedstr2l( str, idx ) );
                setAllFacesColor( *currentColor() );
            }
            if ( str[idx] == 'P' )
            {
                SerialPort::nextValue( str, idx);
                currentColor()->setBlue( SerialPort::embeddedstr2l( str, idx ) );
                setAllFacesColor( *currentColor() );
            }
            if ( str[idx] == 'I' )
            {
                SerialPort::nextValue( str, idx);
                currentColor()->setAlpha( SerialPort::embeddedstr2l( str, idx ) );
                setAllFacesColor( *currentColor() );
            }
            SerialPort::nextField( str, idx);
        }
    }
        break;
    case MCODE_LABVIEW_GET_FACE_RGB:
    {
  /*      SerialPort::nextField( str, idx);
        Face* face = &_top;
        while ( idx < size )
        {
            if ( str[idx] == 'S' )
            {
                SerialPort::nextValue( str, idx);
                face
            }
            if ( str[idx] == 'R' )
            {
                SerialPort::nextValue( str, idx);
                _currentColor.setRed( SerialPort::embeddedstr2l( str, idx ) );
            }
            if ( str[idx] == 'E' )
            {
                SerialPort::nextValue( str, idx);
                _currentColor.setGreen( SerialPort::embeddedstr2l( str, idx ) );
            }
            if ( str[idx] == 'P' )
            {
                SerialPort::nextValue( str, idx);
                _currentColor.setBlue( SerialPort::embeddedstr2l( str, idx ) );
            }
            if ( str[idx] == 'I' )
            {
                SerialPort::nextValue( str, idx);
                _currentColor.setAlpha( SerialPort::embeddedstr2l( str, idx ) );
            }
            SerialPort::nextField( str, idx);
        }*/
    }
        break;
    case MCODE_LABVIEW_GET_GLOBAL_I:
    {
        SerialPort::nextField( str, idx);
        while ( idx < size )
        {
            if ( str[idx] == 'X' )
            {
                SerialPort::nextValue( str, idx);

                setAllFacesLight( SerialPort::embeddedstr2l( str, idx ), true, false );

            }
            if ( str[idx] == 'Y' )
            {
                SerialPort::nextValue( str, idx);
                setAllFacesLight( SerialPort::embeddedstr2l( str, idx ), false, true );
            }
            SerialPort::nextField( str, idx);
        }
        /*SerialPort::nextField( str, idx);
        SerialPort::parseTrueFalse( &_, str[idx] );*/
    }
        break;
    case MCODE_LABVIEW_GET_FACE_I:
    {
        SerialPort::nextField( str, idx);
        int x, y, id ;
        x=y=id=0;
        while ( idx < size )
        {
            if ( str[idx] == 'P' )
            {
                SerialPort::nextValue( str, idx);
                id = SerialPort::embeddedstr2l( str, idx );
            }
            if ( str[idx] == 'X' )
            {
                SerialPort::nextValue( str, idx);
                x = SerialPort::embeddedstr2l( str, idx );
                setFaceLight( SerialPort::embeddedstr2l( str, idx ), false, true );
            }
            if ( str[idx] == 'Y' )
            {
                SerialPort::nextValue( str, idx);
                y = SerialPort::embeddedstr2l( str, idx );
                setFaceLight( SerialPort::embeddedstr2l( str, idx ), false, true );
            }
            SerialPort::nextField( str, idx);
        }
        setFaceLight( id, x, y );
    }
        break;
    default:
        break;
    }
   emit updateUI();
}
Ejemplo n.º 21
0
void AskColorDialog::updateHex(){
	QString oldText = hexcode->text();
	if (QString2QColor(oldText)!=currentColor())
	  hexcode->setText( QColor2QString(currentColor()) );
}