bool KstViewLabel::fillConfigWidget(QWidget *w, bool isNew) const {
  ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w);
  if (!widget) {
    return false;
  }

  if (!isNew) {
    widget->_text->setText(text());
  }

  widget->_precision->setValue(int(dataPrecision()));
  widget->_rotation->setValue(double(rotation()));
  widget->_fontSize->setValue(int(fontSize()));
  widget->_horizontal->setCurrentItem(horizJustifyWrap());
  widget->_fontColor->setColor(foregroundColor());
  widget->_font->setCurrentFont(fontName());

  widget->_transparent->setChecked(transparent());
  widget->_border->setValue(borderWidth());
  widget->_boxColors->setForeground(borderColor());
  widget->_boxColors->setBackground(backgroundColor());
  widget->_margin->setValue(labelMargin());

  widget->_text->setFocus();

  return true;
}
Beispiel #2
0
bool World::bresenham(int x0, int y0, int x1, int y1, int z,
                      const BresenhamBackTransformation& transformation) const {
    int a = y1 - y0;
    int b = x0 - x1;
    float m = (float)(y1 - y0) / (float)(x1 - x0);
    float t = (float)y0 - m * (float)x0;
    int c = roundf((float)(x1 - x0) * t);
    int dE = 2 * a;
    int dNE = 2 * (a + b);
    int d = 2 * a * (x0 + 1) + b * (2 * y0 + 1) + 2 * c;
    int current_x = x0;
    int current_y = y0;
    while (current_x < x1 || current_y < y1) {
        if (d > 0) {
            // NE
            d += dNE;
            current_x++;
            current_y++;
        } else {
            // E
            d += dE;
            current_x++;
        }
        
        if (!transparent(transformation.x(current_x, current_y),
                         transformation.y(current_x, current_y), z)) {
            if (current_x == x1 && current_y == y1) {
                return true;
            }
            return false;
        }
    }
    return true;
}
Beispiel #3
0
void
Canvas::DrawText(int x, int y, const TCHAR *text)
{
    assert(text != nullptr);
#ifndef UNICODE
    assert(ValidateUTF8(text));
#endif

    auto s = RenderText(font, text);
    if (s.data == nullptr)
        return;

    SDLRasterCanvas canvas(buffer);

    if (background_mode == OPAQUE) {
        OpaqueAlphaPixelOperations<SDLPixelTraits, GreyscalePixelTraits>
        opaque(canvas.Import(background_color), canvas.Import(text_color));
        canvas.CopyRectangle<decltype(opaque), GreyscalePixelTraits>
        (x, y, s.width, s.height,
         GreyscalePixelTraits::const_pointer_type(s.data),
         s.pitch, opaque);
    } else {
        ColoredAlphaPixelOperations<SDLPixelTraits, GreyscalePixelTraits>
        transparent(canvas.Import(text_color));
        canvas.CopyRectangle<decltype(transparent), GreyscalePixelTraits>
        (x, y, s.width, s.height,
         GreyscalePixelTraits::const_pointer_type(s.data),
         s.pitch, transparent);
    }
}
 void OverlayMenuDisplay::openingAnimation()
 {
   ROS_DEBUG("openningAnimation");
   prepareOverlay();
   int current_width = animation_t_ / animate_duration * overlay_->getTextureWidth();
   int current_height = animation_t_ / animate_duration * overlay_->getTextureHeight();
   {
     ScopedPixelBuffer buffer = overlay_->getBuffer();
     QColor bg_color(0, 0, 0, 255.0 / 2.0);
     QColor transparent(0, 0, 0, 0.0);
     QImage Hud = buffer.getQImage(*overlay_);
     for (int i = 0; i < overlay_->getTextureWidth(); i++) {
       for (int j = 0; j < overlay_->getTextureHeight(); j++) {
         if (i > (overlay_->getTextureWidth() - current_width) / 2.0 &&
             i < overlay_->getTextureWidth() - (overlay_->getTextureWidth() - current_width) / 2.0 &&
             j > (overlay_->getTextureHeight() - current_height) / 2.0 &&
             j < overlay_->getTextureHeight() - (overlay_->getTextureHeight() - current_height) / 2.0) {
           Hud.setPixel(i, j, bg_color.rgba());
         }
         else {
           Hud.setPixel(i, j, transparent.rgba());
         }
       }
     }
   }
   overlay_->setDimensions(overlay_->getTextureWidth(), overlay_->getTextureHeight());
   int window_width = context_->getViewManager()->getRenderPanel()->width();
   int window_height = context_->getViewManager()->getRenderPanel()->height();
   double window_left = (window_width - (int)overlay_->getTextureWidth()) / 2.0;
   double window_top = (window_height - (int)overlay_->getTextureHeight()) / 2.0;
   overlay_->setPosition(window_left, window_top);
                         
   current_menu_ = next_menu_;
 }
Beispiel #5
0
void
Canvas::DrawTransparentText(int x, int y, const TCHAR *text)
{
  assert(text != nullptr);
#ifndef UNICODE
  assert(ValidateUTF8(text));
#endif

#ifdef ENABLE_OPENGL
  /*
   * RenderText return buffer owned by TextCache, this can be delete by GUI Thread
   *  lock is need for avoid to used alredy deleted buffer.
   */
  TextCache::Lock();
#endif
  
  auto s = RenderText(font, text);
  if (s.data != nullptr) {

    SDLRasterCanvas canvas(buffer);
    ColoredAlphaPixelOperations<ActivePixelTraits, GreyscalePixelTraits>
      transparent(canvas.Import(text_color));
    canvas.CopyRectangle<decltype(transparent), GreyscalePixelTraits>
      (x, y, s.width, s.height,
       GreyscalePixelTraits::const_pointer_type(s.data),
       s.pitch, transparent);
  }
  
#ifdef ENABLE_OPENGL  
  TextCache::Unlock();
#endif  
}
Beispiel #6
0
void ImageItem::paintEvent(QPaintEvent * e)
{
	QPainter pw(this);


	// Actual fading
	QPixmap transparent(mPixmap.size());
	transparent.fill(QColor(200,200,200,128));
	QPainter p(&transparent);
	p.setCompositionMode(QPainter::CompositionMode_SourceOver);
	p.drawPixmap(0,0, mPixmap);
	if(!mInfoText.isEmpty())
	{
		p.setPen( Qt::black );
		p.drawText(4,4,transparent.rect().width(),transparent.rect().height(),
				   Qt::AlignTop | Qt::TextWordWrap,
				   mInfoText);
	}
	p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
	p.fillRect(transparent.rect(), QColor(0, 0, 0, mFade));

	p.end();

	pw.drawPixmap(0,0, transparent);



}
Beispiel #7
0
const QPixmap *TransparentTop::background(QColor c)
{
#if defined(USE_KDE) && defined(HAVE_KROOTPIXMAP_H)
    if (useTransparent() && !saveBG.isNull()){
        if ((c.rgb() == genColor.rgb()) && (transparent() == genFade))
            return &genBG;
        QImage img = saveBG.convertToImage();
        fade(img, transparent() / 100., c);
        genBG.convertFromImage(img);
        genFade = transparent();
        genColor = c;
        return &genBG;
    }
#endif
    return NULL;
}
 void GISCircleVisualizer::update(float wall_dt, float ros_dt)
 {
   ros::WallTime now = ros::WallTime::now();
   std::string text = text_ + " ";
   {
     ScopedPixelBuffer buffer = texture_object_->getBuffer();
     QColor transparent(0, 0, 0, 0);
     QColor foreground = rviz::ogreToQt(color_);
     QColor white(255, 255, 255, color_.a * 255);
     QImage Hud = buffer.getQImage(128, 128, transparent);
     double line_width = 5;
     double inner_line_width = 10;
     double l = 128;
     //double cx = l / 2 - line_width / 4.0;
     double cx = l / 2;
     //double cy = l / 2 - line_width / 4.0;
     double cy = l / 2;
     double r = 48;
     double inner_r = 40;
     double mouse_r = 30;
     double mouse_cy_offset = 5;
     
     QPainter painter( &Hud );
     painter.setRenderHint(QPainter::Antialiasing, true);
     painter.setPen(QPen(foreground, line_width, Qt::SolidLine));
     painter.setBrush(white);
     painter.drawEllipse(line_width / 2.0, line_width / 2.0,
                         l - line_width, l - line_width);
     double offset_rate = fmod(now.toSec(), 10) / 10.0;
     double theta_offset = offset_rate * M_PI * 2.0;
     for (size_t ci = 0; ci < text.length(); ci++) {
       double theta = M_PI * 2.0 / text.length() * ci + theta_offset;
       painter.save();
       QFont font("DejaVu Sans Mono");
       font.setPointSize(8);
       font.setBold(false);
       painter.setFont(font);
       painter.translate(cx + r * cos(theta),
                         cy + r * sin(theta));
       painter.rotate(theta / M_PI * 180 + 90);
       painter.drawText(0, 0, text.substr(ci, 1).c_str());
       painter.restore();
     }
     painter.setPen(QPen(foreground, inner_line_width, Qt::SolidLine));
     painter.setBrush(transparent);
     painter.drawEllipse(cx - inner_r, cy - inner_r,
                         inner_r * 2, inner_r * 2);
     double mouse_c_x = cx;
     double mouse_c_y = cy - mouse_cy_offset;
     double start_angle = -25 * M_PI / 180;
     double end_angle = -125 * M_PI / 180;
     painter.setPen(QPen(foreground, line_width, Qt::SolidLine));
     painter.drawChord(mouse_c_x - mouse_r, mouse_c_y - mouse_r,
                       2.0 * mouse_r, 2.0 * mouse_r,
                       start_angle * 180 / M_PI * 16,
                       end_angle * 180 / M_PI * 16);
     painter.end();
   }
 }
//======================================================= release
//===============================================================
int  TFWidgetRen::release()
{
  //if(pickedObj == LEVWIDGNAME)
  //return tris->release();
  transparent();
  //pickedTri = 0;
  return 1;
}
Beispiel #10
0
void KisKraLoaderTest::testLoadAnimated()
{
    KisDocument *doc = KisPart::instance()->createDocument();
    doc->loadNativeFormat(QString(FILES_DATA_DIR) + QDir::separator() + "load_test_animation.kra");
    KisImageSP image = doc->image();

    KisNodeSP node1 = image->root()->firstChild();
    KisNodeSP node2 = node1->nextSibling();

    QVERIFY(node1->inherits("KisPaintLayer"));
    QVERIFY(node2->inherits("KisPaintLayer"));

    KisPaintLayerSP layer1 = qobject_cast<KisPaintLayer*>(node1.data());
    KisPaintLayerSP layer2 = qobject_cast<KisPaintLayer*>(node2.data());
    KisKeyframeChannel *channel1 = layer1->getKeyframeChannel(KisKeyframeChannel::Content.id());
    KisKeyframeChannel *channel2 = layer2->getKeyframeChannel(KisKeyframeChannel::Content.id());

    QCOMPARE(channel1->keyframeCount(), 3);
    QCOMPARE(channel2->keyframeCount(), 1);

    QCOMPARE(image->animationInterface()->framerate(), 17);
    QCOMPARE(image->animationInterface()->fullClipRange(), KisTimeRange::fromTime(15, 45));
    QCOMPARE(image->animationInterface()->currentTime(), 19);

    KisPaintDeviceSP dev = layer1->paintDevice();

    const KoColorSpace *cs = dev->colorSpace();
    KoColor transparent(Qt::transparent, cs);
    KoColor white(Qt::white, cs);
    KoColor red(Qt::red, cs);

    image->animationInterface()->switchCurrentTimeAsync(0);
    image->waitForDone();

    QCOMPARE(dev->exactBounds(), QRect(506, 378, 198, 198));
    QCOMPARE(dev->x(), -26);
    QCOMPARE(dev->y(), -128);
    QCOMPARE(dev->defaultPixel(), transparent);

    image->animationInterface()->switchCurrentTimeAsync(20);
    image->waitForDone();

    QCOMPARE(dev->nonDefaultPixelArea(), QRect(615, 416, 129, 129));
    QCOMPARE(dev->x(), 502);
    QCOMPARE(dev->y(), 224);
    QCOMPARE(dev->defaultPixel(), white);

    image->animationInterface()->switchCurrentTimeAsync(30);
    image->waitForDone();

    QCOMPARE(dev->nonDefaultPixelArea(), QRect(729, 452, 45, 44));
    QCOMPARE(dev->x(), 645);
    QCOMPARE(dev->y(), -10);
    QCOMPARE(dev->defaultPixel(), red);
}
QRegion KstPlotGroup::clipRegion() {
  if (transparent()) {
    // make the clipregion just the children
    QRegion region;
    for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
      region += (*i)->clipRegion();
    }
    return region;
  }
  return KstViewObject::clipRegion();
}
Beispiel #12
0
/** fill the custom widget with current properties */
bool KstViewLegend::fillConfigWidget(QWidget *w, bool isNew) const {
  ViewLegendWidget *widget = dynamic_cast<ViewLegendWidget*>(w);
  if (!widget) {
    return false;
  }

  KstBaseCurveList allCurves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList);
  
  if (isNew) {
    widget->_fontSize->setValue(0);
    widget->_fontColor->setColor(KstSettings::globalSettings()->foregroundColor);
    widget->_font->setCurrentFont(KstApp::inst()->defaultFont());
    widget->_margin->setValue(5);
    widget->_boxColors->setColor(KstSettings::globalSettings()->foregroundColor);
    widget->_vertical->setChecked(true);
    widget->_transparent->setChecked(false);
    widget->_border->setValue(2);
    widget->_title->setText("");
    widget->TrackContents->setChecked(true);
 
    for (KstBaseCurveList::ConstIterator it = allCurves.begin(); it != allCurves.end(); ++it) {
      (*it)->readLock();
      widget->AvailableCurveList->insertItem((*it)->tagName());
      (*it)->unlock();
    }

  } else { // fill legend properties into widget
    widget->TrackContents->setChecked(trackContents());
    widget->_title->setText(title());
    widget->_fontSize->setValue(int(fontSize()));
    widget->_fontColor->setColor(foregroundColor());
    widget->_font->setCurrentFont(fontName());
    widget->_transparent->setChecked(transparent());
    widget->_border->setValue(borderWidth());
    widget->_boxColors->setColor(borderColor());
    widget->_margin->setValue(_legendMargin);
    widget->_vertical->setChecked(vertical());
    for (KstBaseCurveList::ConstIterator it = _curves.begin(); it != _curves.end(); ++it) {
      (*it)->readLock();
      widget->DisplayedCurveList->insertItem((*it)->tagName());
      (*it)->unlock();
    }
    for (KstBaseCurveList::ConstIterator it = allCurves.begin(); it != allCurves.end(); ++it) {
      (*it)->readLock();
      if (_curves.find(*it) == _curves.end()) {
        widget->AvailableCurveList->insertItem((*it)->tagName());
      }
      (*it)->unlock();
    }
  }
  return false;
}
void CrossFaderWidget::takeAndStoreSnapshotsAboutWidgets(QWidget *sourceWidget, QWidget *targetWidget)
{
    // grab a snapshots of the widgets

    // source
    {
        sourceWidgetSnapshot = QPixmap::grabWidget(sourceWidget);

        // Create new picture for transparent
        QPixmap transparent(sourceWidgetSnapshot.size());

        // Do transparency
        transparent.fill(Qt::transparent);
        QPainter p(&transparent);
        p.setCompositionMode(QPainter::CompositionMode_Source);
        p.drawPixmap(0, 0, sourceWidgetSnapshot);

        // Set original picture's reference to new transparent one
        sourceWidgetSnapshot = transparent;
    }

    // target
    {
        targetWidgetSnapshot = QPixmap::grabWidget(targetWidget);

        // Create new picture for transparent
        QPixmap transparent(targetWidgetSnapshot.size());
        //            QPixmap transparent(targetWidget.size());

        // Do transparency
        transparent.fill(Qt::transparent);
        QPainter p(&transparent);
        p.setCompositionMode(QPainter::CompositionMode_Source);
        p.drawPixmap(0, 0, targetWidgetSnapshot);

        // Set original picture's reference to new transparent one
        targetWidgetSnapshot = transparent;
    }
}
Beispiel #14
0
void gpsp4Qt::ApplyTransparency(QPixmap &pm, QString png)
{
    pm.load(png);
    QPixmap transparent(pm.size());
    transparent.fill(Qt::transparent);
    QPainter p(&transparent);
    p.setCompositionMode(QPainter::CompositionMode_Source);
    p.drawPixmap(0, 0, pm);
    p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
    p.fillRect(transparent.rect(), QColor(0, 0, 0, (m_settings.iButtonOpacity * 255) / 4));
    p.end();
    pm = transparent;
}
Beispiel #15
0
bool KstViewLabel::fillConfigWidget(QWidget *w, bool isNew) const {
  ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w);
  if (!widget) {
    return false;
  }
  
  if (isNew) { // probably a new label: set widget to defaults
    widget->_precision->setValue(8);
    widget->_rotation->setValue(0);
    widget->_fontSize->setValue(0);
    widget->_horizontal->setCurrentItem(0);
    widget->_fontColor->setColor(KstSettings::globalSettings()->foregroundColor);
    widget->_font->setCurrentFont(KstApp::inst()->defaultFont());
    widget->_margin->setValue(5);

    widget->_boxColors->setColor(KstSettings::globalSettings()->backgroundColor);

    if (size().width() * size().height() < 25) { // assume a click, and default to just text
      widget->_transparent->setChecked(true);
      widget->_border->setValue(0);
    } else { // someone drew a box, so assume that is what they wanted
      widget->_transparent->setChecked(false);
      widget->_border->setValue(2);
    }

  } else {
    // No, this is broken.  It kills latex.
#if 0
    // replace \n & \t with tabs and newlines for the text edit box
    QString tmpstr = text();
    tmpstr.replace(QString("\\n"), "\n");
    tmpstr.replace(QString("\\t"), "\t");
    widget->_text->setText(tmpstr);
#endif
    widget->_text->setText(text());

    widget->_precision->setValue(int(dataPrecision()));
    widget->_rotation->setValue(double(rotation()));
    widget->_fontSize->setValue(int(fontSize()));
    widget->_horizontal->setCurrentIndex(horizJustifyWrap());
    widget->_fontColor->setColor(foregroundColor());
    widget->_font->setCurrentFont(fontName());

    widget->_transparent->setChecked(transparent());
    widget->_border->setValue(borderWidth());
    widget->_boxColors->setColor(borderColor());
    widget->_margin->setValue(_labelMargin);
  }
  widget->_text->setFocus();
  return true;
}
Beispiel #16
0
Material::Material(Material_t tag)
    : tag(tag),
      vertexShader(this),
      fragmentShader(this),
      index0AttributeName(this)
{
    mId = Material::MaterialIdCount++;

    mUuid = Math::generateUUID();

    mName = "";

    side() = kFrontSide;

    opacity() = 1.0f;
    transparent() = false;

    blending() = kNormalBlending;

    blendSrc() = kSrcAlphaFactor;
    blendDst() = kOneMinusSrcAlphaFactor;
    blendEquation() = kAddEquation;

    depthTest() = true;
    depthWrite() = true;

    polygonOffset() = false;
    polygonOffsetFactor() = 0;
    polygonOffsetUnits() = 0;

    // mAlphaTest = 0;

    overdraw() = 0; // Overdrawn pixels (typically between 0 and 1) for fixing antialiasing gaps in CanvasRenderer

    visible() = true;

    needsUpdate() = true;

    // By default, bind position to attribute index 0. In WebGL, attribute 0
    // should always be used to avoid potentially expensive emulation.
    index0AttributeName("position");

    linewidth() = 1.0f;
    metal() = false;
    perPixel() = true;
    shading() = kNoShading;
	vertexColors() = kNoColors;
    wireframe() = false;
    wireframeLinewidth() = 1.0f;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void PipelineFilterWidget::mouseMoveEvent(QMouseEvent* event)
{
    if(!(event->buttons() & Qt::LeftButton))
    {
        return;
    }
    if((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance())
    {
        return;
    }
    // The user is dragging the filter widget so we should set it as selected.
    setIsSelected(true);
    QPixmap pixmap = grab();

    // Create new picture for transparent
    QPixmap transparent(pixmap.size());
    // Do transparency
    transparent.fill(Qt::transparent);
#if 1
    QPainter p;
    p.begin(&transparent);
    p.setOpacity(0.70);
    p.drawPixmap(0, 0, pixmap);
    p.end();
#endif

    QByteArray itemData;
    QDataStream dataStream(&itemData, QIODevice::WriteOnly);
    dataStream << transparent << QPoint(event->pos());

    QMimeData* mimeData = new QMimeData;
    mimeData->setData("application/x-dnditemdata", itemData);

    QDrag* drag = new QDrag(this);
    drag->setMimeData(mimeData);
    drag->setPixmap(transparent);
    drag->setHotSpot(event->pos());

    emit dragStarted(this);

    //  if(drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction)
    //  {
    //    qDebug() << "Drag should close the widget because it was MOVE" << "\n";
    //  }
    //  else
    //  {
    //    qDebug() << "Drag should leave Widget alone because it was COPY" << "\n";
    //  }
    drag->exec(Qt::MoveAction);
}
Beispiel #18
0
void QuickLauncher::updateStickyHighlightLayer()
{
    // Creates a transparent image which is used
    // to highlight those buttons which will never
    // be removed automatically from the launcher
    TQPixmap areaPix(width(), height());
    TQPainter areaPixPainter(&areaPix);
    areaPixPainter.fillRect(0, 0, width(), height(), TQColor(255, 255, 255));
    TQSize itemSize = m_manager->itemSize();
    TQSize spaceSize = m_manager->spaceSize();
    for (uint n=0; n<m_buttons->size(); ++n)
    {
        TQPoint pos = m_manager->pos(n);
        if ((*m_buttons)[n]->sticky() == false)
        {
            areaPixPainter.fillRect(pos.x()-(spaceSize.width()+1)/2, 
                                    pos.y()-(spaceSize.height()+1)/2, 
                                    itemSize.width()+spaceSize.width()+1, 
                                    itemSize.height()+spaceSize.height()+1, 
                                    TQColor(0, 0, 0));
        }
    }
    TQImage areaLayer = areaPix.convertToImage();
    m_stickyHighlightLayer = TQImage(width(), height(), 32);
    m_stickyHighlightLayer.setAlphaBuffer(true);
    int pix, tlPix, brPix, w(width()), h(height());
    QRgb transparent(tqRgba(0, 0, 0, 0));
    for (int y = h-1; y >= 0; --y)
    {
        for (int x = w-1; x >= 0; --x)
        {
            pix = tqRed(areaLayer.pixel(x, y));
            if (pix == 0)
            {
                tlPix = (y>0 && x>0) ? tqRed(areaLayer.pixel(x-1,y-1)) : 255;
                brPix = (y<h-1 && x<w-1) ? tqRed(areaLayer.pixel(x+1,y+1)) : 255;
                int c = tlPix-brPix < 0 ? 255 : 0;
                int alpha = abs(tlPix-brPix)/2;
                m_stickyHighlightLayer.setPixel(x, y, tqRgba(c, c, c, alpha));
            }
            else 
            {
                m_stickyHighlightLayer.setPixel(x, y, transparent);
            }
        }
    }
    repaint();
}
Beispiel #19
0
static void
CopyTextRectangle(SDLRasterCanvas &canvas, int x, int y,
                  unsigned width, unsigned height,
                  TextCache::Result s,
                  Color text_color, Color background_color, bool opaque)
{
  if (opaque) {
    OpaqueAlphaPixelOperations<ActivePixelTraits, GreyscalePixelTraits>
      opaque(canvas.Import(background_color), canvas.Import(text_color));
    CopyTextRectangle(canvas, x, y, width, height, opaque, s);
  } else {
    ColoredAlphaPixelOperations<ActivePixelTraits, GreyscalePixelTraits>
      transparent(canvas.Import(text_color));
    CopyTextRectangle(canvas, x, y, width, height, transparent, s);
  }
}
void KstPlotGroup::paintSelf(KstPainter& p, const QRegion& bounds) {
  if (!transparent()) {
    p.save();
    // fill non-children areas with color
    QRegion clipRegion(contentsRect());
    QBrush brush(_backgroundColor);
    for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
      clipRegion -= (*i)->clipRegion();
    }
    p.setClipRegion(clipRegion);
    p.fillRect(contentsRect(), brush);
    p.restore();
  }

  KstMetaPlot::paintSelf(p, bounds);
}
Beispiel #21
0
void
Canvas::DrawTransparentText(int x, int y, const TCHAR *text)
{
  assert(text != nullptr);
#ifndef UNICODE
  assert(ValidateUTF8(text));
#endif

  auto s = RenderText(font, text);
  if (s.data == nullptr)
    return;

  SDLRasterCanvas canvas(buffer);
  ColoredAlphaPixelOperations<ActivePixelTraits, GreyscalePixelTraits>
    transparent(canvas.Import(text_color));
  CopyTextRectangle(canvas, x, y, s.width, s.height, transparent, s);
}
Beispiel #22
0
void tst_QPixmap::transformed()
{
    QFETCH(QSize, size);
    QFETCH(QTransform, transform);
    QFETCH(Qt::TransformationMode, transformMode);

    QPixmap opaque(size);
    QPixmap transparent(size);
    opaque.fill(QColor(255, 0, 0));
    transparent.fill(QColor(255, 0, 0, 200));

    QPixmap transformed1;
    QPixmap transformed2;
    QBENCHMARK {
        transformed1 = opaque.transformed(transform, transformMode);
        transformed2 = transparent.transformed(transform, transformMode);
    }
}
Beispiel #23
0
void
Canvas::DrawClippedText(int x, int y, unsigned max_width, const TCHAR *text)
{
  static TCHAR text_buffer[256];
  assert(text != NULL);
#ifndef UNICODE
  assert(ValidateUTF8(text));
#endif
  const TCHAR *clipped_text = text;
  unsigned width = Canvas::CalcTextWidth(text);
  if (width > max_width) {
    #warning "that wrong, does not handle multibyte char."
    unsigned new_size;
    fixed target_percent = fixed(max_width) / fixed(width);
    new_size = fixed(StringLength(text)) * target_percent;
    CopyString(text_buffer, text, std::min(new_size, 256u));
    clipped_text = text_buffer;
  }
  
#ifndef UNICODE
  assert(ValidateUTF8(clipped_text));
#endif
  
  auto s = RenderText(font, clipped_text);
  if (s.data == nullptr)
    return;

  SDLRasterCanvas canvas(buffer);
  if (background_mode == OPAQUE) {
    OpaqueAlphaPixelOperations<ActivePixelTraits, GreyscalePixelTraits>
      opaque(canvas.Import(background_color), canvas.Import(text_color));
    canvas.CopyRectangle<decltype(opaque), GreyscalePixelTraits>
      (x, y, s.width, s.height,
       GreyscalePixelTraits::const_pointer_type(s.data),
       s.pitch, opaque);
  } else {
    ColoredAlphaPixelOperations<ActivePixelTraits, GreyscalePixelTraits>
      transparent(canvas.Import(text_color));
    canvas.CopyRectangle<decltype(transparent), GreyscalePixelTraits>
      (x, y, s.width, s.height,
       GreyscalePixelTraits::const_pointer_type(s.data),
       s.pitch, transparent);
  }
}
Beispiel #24
0
void tst_QPixmap::scaled()
{
    QFETCH(QSize, size);
    QFETCH(QSize, scale);
    QFETCH(Qt::AspectRatioMode, ratioMode);
    QFETCH(Qt::TransformationMode, transformMode);

    QPixmap opaque(size);
    QPixmap transparent(size);
    opaque.fill(QColor(255, 0, 0));
    transparent.fill(QColor(255, 0, 0, 200));

    QPixmap scaled1;
    QPixmap scaled2;
    QBENCHMARK {
        scaled1 = opaque.scaled(scale, ratioMode, transformMode);
        scaled2 = transparent.scaled(scale, ratioMode, transformMode);
    }
}
 void PictogramObject::update(float wall_dt, float ros_dt)
 {
   if (text_.empty()) {
     // not yet setted
     return;
   }
   // update position and orientation
   if (!context_) {
     return;
   }
   updatePose(wall_dt);
   if (!need_to_update_) {
     return;
   }
   need_to_update_ = false;
   ScopedPixelBuffer buffer = texture_object_->getBuffer();
   QColor transparent(255, 255, 255, 0);
   QImage Hud = buffer.getQImage(128, 128, transparent); // should change according to size
   QPainter painter( &Hud );
   painter.setRenderHint(QPainter::Antialiasing, true);
   QColor foreground = rviz::ogreToQt(color_);
   painter.setPen(QPen(foreground, 5, Qt::SolidLine));
   
   if (isCharacterSupported(text_)) {
     QFont font = getFont(text_);
     QString pictogram_text = lookupPictogramText(text_);
     if (isEntypo(text_)) {
       font.setPointSize(100);
     }
     else if (isFontAwesome(text_)) {
       font.setPointSize(45);
     }
     painter.setFont(font);
     painter.drawText(0, 0, 128, 128,
                      Qt::AlignHCenter | Qt::AlignVCenter,
                      pictogram_text);
     painter.end();
   }
   else {
     ROS_WARN("%s is not supported", text_.c_str());
   }
 }
Beispiel #26
0
void SkirmishMenuState::drawSpecifics()
{
    DataCache::Instance()->getGameData("BigPlanet")->getImage();

    ImagePtr houseChoice = DataCache::Instance()->getGameData("UI_HouseChoiceBackground")->getImage()->getCopy();
    houseChoice->drawBorders1();
    Rect area(20, 53, 300, 53+95);
    houseChoice->greyOut(area);
    m_middleFrame->changeBackground(houseChoice);
    m_selectionBox->setPosition(area.getPosition() - 1);
    m_selectionBox->setSize(area.getSize());
    m_middleFrame->addChild(m_selectionBox);

    ImagePtr atreides = DataCache::Instance()->getGameData("UI_HeraldColoredAtreides")->getImage();
    ImagePtr transparent(new Image(atreides->getSize()));

    transparent->setColorKey();
    GraphicButton *atreidesButton = new GraphicButton(transparent, atreides);
    atreidesButton->setPosition(UPoint(0, 0));
    atreidesButton->onClick.connect(
            boost::bind(&SkirmishMenuState::setHouse, this, HOUSE_ATREIDES));

    m_selectionBox->addChild(atreidesButton);

    ImagePtr ordos = DataCache::Instance()->getGameData("UI_HeraldColoredOrdos")->getImage();
    transparent->setColorKey();
    GraphicButton *ordosButton = new GraphicButton(transparent, ordos);
    ordosButton->setPosition(UPoint(96, 0));
    ordosButton->onClick.connect(
            boost::bind(&SkirmishMenuState::setHouse, this, HOUSE_ORDOS));
    m_selectionBox->addChild(ordosButton);

    ImagePtr harkonnen = DataCache::Instance()->getGameData("UI_HeraldColoredHarkonnen")->getImage();
    transparent->setColorKey();
    GraphicButton *harkonnenButton = new GraphicButton(transparent, harkonnen);
    harkonnenButton->setPosition(UPoint(194, 0));
    harkonnenButton->onClick.connect(
            boost::bind(&SkirmishMenuState::setHouse, this, HOUSE_HARKONNEN));
    m_selectionBox->addChild(harkonnenButton);

    m_missionLabel->redraw();
}
Beispiel #27
0
void RenderArea::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    QImage transparent(600, 600, QImage::Format_ARGB32_Premultiplied);
    transparent.fill(QColor(0,0,0,0).rgba());

    switch (shape) {
    case RenderArea::Line:
        if (dragging) {
            drawLine(&transparent);
        } else {
            drawLine(&image);
        }
        break;
    case RenderArea::AALine:
        if (dragging) {
            drawAALine(&transparent);
        } else {
            drawAALine(&image);
        }
        break;
    case RenderArea::Circle:
        if (dragging) {
            drawCircle(&transparent);
        } else {
            drawCircle(&image);
        }
        break;
    case RenderArea::FilledCircle:
        if (dragging) {
            drawFilledCircle(&transparent);
        } else {
            drawFilledCircle(&image);
        }
        break;
    }

    painter.drawImage(QPoint(0, 0), image);
    if (dragging)
        painter.drawImage(QPoint(0, 0), transparent);
}
Beispiel #28
0
void GPS::initializeImages(){
    QPixmap gpsPix;
    gpsPix.load(":gps");

    // Create new picture for transparent
    QPixmap transparent(gpsPix.size());

    // Do transparency
    transparent.fill(Qt::transparent);
    QPainter p(&transparent);
    p.setCompositionMode(QPainter::CompositionMode_Source);
    p.drawPixmap(0, 0, gpsPix);
    p.setCompositionMode(QPainter::CompositionMode_DestinationIn);

    // Set transparency level to 150 (possible values are 0-255)
    p.fillRect(transparent.rect(), QColor(0, 0, 0, 150));
    p.end();

    // Set original picture's reference to new transparent one
    gpsPix = transparent;

    gps = new QGraphicsPixmapItem(gpsPix);

    halfSizeImage = gpsPix.size().height() / 2;

    gps->setTransformationMode(Qt::SmoothTransformation);
    gps->setScale(sizes[index]);
    gps->setOffset(-halfSizeImage, -halfSizeImage);

    QFont b;
    gpsScene->addItem(gps);
    b.setStyleHint(QFont::Decorative);
    b.setBold(true);
    b.setPointSize(16);

    latitude=gpsScene->addSimpleText("Latitude: 0",b);
    longitude=gpsScene->addSimpleText("Longitude: 0",b);

    latitude->setPos(latitudePosition.x() * sizes[index] - halfSizeImage * sizes[index], latitudePosition.y() * sizes[index] - halfSizeImage * sizes[index]);
    longitude->setPos(longitudePosition.x() * sizes[index] - halfSizeImage * sizes[index], longitudePosition.y() * sizes[index] - halfSizeImage * sizes[index]);
}
Beispiel #29
0
void Graphic::drawImageWithAlpha(Image image) {
	SDL_Surface* tempScreen = NULL;

	if ((tempScreen = SDL_CreateRGBSurface(SDL_HWSURFACE | SDL_SRCALPHA | SDL_DOUBLEBUF, image.getSurface()->w, image.getSurface()->h, 32, 0, 0, 0, 0)) == NULL)
		return;

	if (SDL_SetAlpha(tempScreen, SDL_SRCALPHA, image.alpha) < 0) {
		SDL_FreeSurface(tempScreen);
		tempScreen = NULL;
		return;
	}

	if (!transparent(tempScreen, 0, 0, 0)) {
		SDL_FreeSurface(tempScreen);
		tempScreen = NULL;
		return;
	}

	SDL_Rect destR;
	destR.x = image.x;
	destR.y = image.y;

	SDL_Rect srcR;
	srcR.x = 0;
	srcR.y = 0;
	srcR.w = image.width;
	srcR.h = image.height;

	SDL_BlitSurface(image.getSurface(), &srcR, tempScreen, &destR);

	if (!onDraw(surface, tempScreen, image.x, image.y)) {
		SDL_FreeSurface(tempScreen);
		tempScreen = NULL;
		return;
	}

	SDL_FreeSurface(tempScreen);
	tempScreen = NULL;
}
Beispiel #30
0
void Rectangle::
        test()
{
    std::string name = "Rectangle";
    int argc = 1;
    char * argv = &name[0];
    QApplication a(argc,&argv);

    // It should apply a bandpass and time filter between f1,s1 and f2,s2 to a signal.
    {
        Signal::Processing::Chain::ptr cp = Signal::Processing::Chain::createDefaultChain ();
        Signal::OperationDesc::ptr transparent(new Test::TransparentOperationDesc);
        Signal::OperationDesc::ptr buffersource(new Signal::BufferSource(Test::RandomBuffer::smallBuffer ()));
        Tfr::ChunkFilterDesc::ptr cfd(new Rectangle(1,2,4,4,false));
        Signal::OperationDesc::ptr rectangledesc(new TransformOperationDesc(cfd));
        Signal::Processing::TargetMarker::ptr at = cp->addTarget(transparent);
        Signal::Processing::TargetNeeds::ptr n = at->target_needs();
        cp->addOperationAt(buffersource,at);
        cp->addOperationAt(rectangledesc,at);
        n->updateNeeds(Signal::Interval(0,10));
        EXCEPTION_ASSERT( n->sleep (200) );
    }
}