Ejemplo n.º 1
0
void Buoy::render(QGraphicsItemGroup *layer) {

	QPointF origo(0,0);

	QGraphicsPixmapItem *buoyItem = new QGraphicsPixmapItem(buoy);
	buoyItem->setPos(origo);

        QRectF bb = buoyItem->boundingRect();
        //buoyItem->rotate(90.0f);
        //buoyItem->translate(-bb.width()/2.0f, -bb.height());
        buoyItem->setOffset(-bb.width()/2, -bb.height()*0.8);
        QGraphicsPixmapItem *coneItem = new QGraphicsPixmapItem(lightCone);
        coneItem->setPos(origo);
        coneItem->rotate(180 + lightConeRotation);
        //coneItem->rotate(lightConeRotation);

        bb = coneItem->boundingRect();
        //coneItem->translate(-bb.width()/2.0f, -bb.height());
        coneItem->setOffset(-bb.width()/2, -bb.height()*0.8);
        QGraphicsItemGroup* group = new QGraphicsItemGroup();

        group->addToGroup(buoyItem);
        group->addToGroup(coneItem);
        //group->scale(0.000025, 0.000025);
        group->scale(0.25, 0.25);
	group->setZValue(6.5);
	group->setPos(position);
	group->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
	//TODO: check if i should give and offset to the pixmaps

	layer->addToGroup(group);
}
Ejemplo n.º 2
0
Slideshow::Slideshow(Gallery *gallery, ThumbnailModel *model, QVector<int> selection, QWidget *parent) :
	QGraphicsView(parent), m_gallery(gallery), m_model(model), m_selection(selection), m_picture(0)
{
	setWindowTitle(tr("Slideshow"));
	setAttribute(Qt::WA_DeleteOnClose, true);
	setWindowFlags(windowFlags() | Qt::Window);
	setFrameShape(QFrame::NoFrame);
	setFocusPolicy(Qt::StrongFocus);

	m_scene = new QGraphicsScene();
	m_scene->setBackgroundBrush(Qt::black);

	setScene(m_scene);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setInteractive(false);
	setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);

	m_slidetimer = new QTimer(this);
	connect(m_slidetimer, SIGNAL(timeout()), this, SLOT(nextSlide()));

	// Construct the pause glyph
	QGraphicsLineItem *p1 = new QGraphicsLineItem(QLineF(20, 20, 20, 70));
	QGraphicsLineItem *p2 = new QGraphicsLineItem(QLineF(60, 20, 60, 70));
	QPen pen;
	pen.setWidth(15);
	pen.setCapStyle(Qt::RoundCap);
	pen.setColor(Qt::white);
	p1->setPen(pen);
	p2->setPen(pen);

	QGraphicsItemGroup *pauseglyph = new QGraphicsItemGroup();
	pauseglyph->setZValue(100);
	pauseglyph->addToGroup(p1);
	pauseglyph->addToGroup(p2);
	addShadowEffect(pauseglyph);

	pauseglyph->hide();
	m_pauseglyph = pauseglyph;
	m_scene->addItem(m_pauseglyph);

	// Construct timer text item
	m_timertext = new QGraphicsTextItem();
	m_timertext->setZValue(100);
	QFont font;
	font.setPixelSize(20);
	m_timertext->setFont(font);
	m_timertext->setDefaultTextColor(Qt::white);
	setTimerText();
	addShadowEffect(m_timertext);

	m_timertext->hide();
	m_scene->addItem(m_timertext);

	m_scalefill = gallery->database()->getSetting("slideshow.scale").toString() == "fill";
	m_upscale = gallery->database()->getSetting("slideshow.upscale").toBool();
}
Ejemplo n.º 3
0
/*!
    \fn ULLineEditor::validateLine()
 */
void ULLineEditor::validateLine()
{
// 	clearPreview();
	editing = false;
//	QPainterPath  sel;
//	sel.addRect ( sceneRect() );
//	setSelectionArea ( sel );
	QList<QGraphicsItem*> l;
	foreach(QGraphicsItem* gi, glyphs)
	{
		l << gi;
	}

	QGraphicsItemGroup * g = createItemGroup (l);
//	g->setSelected(false);
//	foreach(QGraphicsItem* i, g->childItems())
//	{
//		i->setSelected(false);
//	}

	m_mainScene->addItem ( g );
	g->setFlags ( QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
	g->setData ( 1,"group" );
	qDebug() << "set data 3 to "<<m_baseLine;
	g->setData ( 3,QVariant ( m_baseLine ) );
	g->setData ( 4,m_marginRight );
	g->setData ( 5,m_curPpos );
	g->setData( 6, (ltr ? 1 : 0) );
	g->setZValue ( 10.0 );
	g->setHandlesChildEvents ( true );
	if ( reedit )
	{
		g->setPos ( reeditPos );
// 		g->moveBy(0.0,-(g->boundingRect().height()));
		g->setData ( 2, QVariant ( reedit_id ) );
		PageBuffer::getInstance()->insert ( reedit_id,glyphs );
		reedit = false;
	}
	else
	{
		g->setData ( 2, QVariant ( PageBuffer::getInstance()->put ( glyphs ) ) );
		g->setPos ( m_mainScene->cur_pos );
		g->moveBy ( 0.0,-m_baseLine );
		m_mainScene->setCur ( m_mainScene->cur_pos.x(), m_mainScene->cur_pos.y() + m_baseLine );
	}
	m_mainScene->views() [0]->centerOn ( g );
	m_curPpos = 0.0;
	adjust();
	glyphs.clear();
	keyLast.clear();
	emit isValidate();

}
Ejemplo n.º 4
0
QGraphicsItemGroup* Document::grid()
{
  QGraphicsItemGroup *group = new QGraphicsItemGroup();
  group->setZValue(-1.0);

  QPen gridPen(QBrush(QColor("#DDDDDD")), 0.0);
  QPen gridPenDec(QBrush(QColor("#AAAAAA")), 0.0);
  QPen *activePen;
  double margin;

  for (int i = 0; i < size_.height() + 1; ++i) {
    if (i % 10 == 0) {
      margin = 10.0;
      activePen = &gridPenDec;
    } else {
      margin = 5.0;
      activePen = &gridPen;
    }

    QGraphicsLineItem *line = new QGraphicsLineItem(-margin,
                                                    10.0 * i,
                                                    10.0 * size_.width() + margin,
                                                    10.0 * i,
                                                    group);
    line->setPen(*activePen);
  }

  for (int i = 0; i < size_.width() + 1; ++i) {
    if (i % 10 == 0) {
      margin = 10.0;
      activePen = &gridPenDec;
    } else {
      margin = 5.0;
      activePen = &gridPen;
    }

    QGraphicsLineItem *line = new QGraphicsLineItem(10.0 * i,
                                                    -margin,
                                                    10.0 * i,
                                                    10.0 * size_.height() + margin,
                                                    group);
    line->setPen(*activePen);
  }

  return group;
}