AbstractConfig::AbstractConfig(AbstractContent * content, AbstractConfig_PARENT * parent) : AbstractConfig_TYPE(parent) , m_content(content) , m_commonUi(new Ui::AbstractConfig()) #if !defined(MOBILE_UI) , m_closeButton(0) , m_okButton(0) #endif , m_frame(FrameFactory::defaultPanelFrame()) { #if !defined(MOBILE_UI) // close button m_closeButton = new StyledButtonItem(tr(" x "), font(), this);//this, ":/data/button-close.png", ":/data/button-close-hovered.png", ":/data/button-close-pressed.png"); connect(m_closeButton, SIGNAL(clicked()), this, SIGNAL(requestClose())); // WIDGET setup (populate contents and set base palette (only) to transparent) QWidget * widget = new QWidget(); m_commonUi->setupUi(widget); QPalette pal; QColor oldColor = pal.window().color(); pal.setBrush(QPalette::Window, Qt::transparent); widget->setPalette(pal); pal.setBrush(QPalette::Window, oldColor); m_commonUi->tab->setPalette(pal); #else m_commonUi->setupUi(this); #endif populateFrameList(); // select the frame quint32 frameClass = m_content->frameClass(); if (frameClass != Frame::NoFrame) { for (int i = 0; i < m_commonUi->framesList->count(); ++i) { QListWidgetItem * item = m_commonUi->framesList->item(i); if (item->data(Qt::UserRole).toUInt() == frameClass) { item->setSelected(true); break; } } } // read other properties m_commonUi->reflection->setChecked(m_content->mirrored()); m_commonUi->contentLocked->setChecked(m_content->locked()); m_commonUi->fixedPosition->setChecked(m_content->fixedPosition()); m_commonUi->fixedRotation->setChecked(m_content->fixedRotation()); m_commonUi->fixedPerspective->setChecked(m_content->fixedPerspective()); connect(m_commonUi->front, SIGNAL(clicked()), m_content, SLOT(slotStackFront())); connect(m_commonUi->raise, SIGNAL(clicked()), m_content, SLOT(slotStackRaise())); connect(m_commonUi->lower, SIGNAL(clicked()), m_content, SLOT(slotStackLower())); connect(m_commonUi->back, SIGNAL(clicked()), m_content, SLOT(slotStackBack())); connect(m_commonUi->save, SIGNAL(clicked()), m_content, SLOT(slotSaveAs())); connect(m_commonUi->background, SIGNAL(clicked()), m_content, SIGNAL(requestBackgrounding())); connect(m_commonUi->del, SIGNAL(clicked()), m_content, SIGNAL(requestRemoval())); connect(m_commonUi->contentLocked, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetLocked(int))); connect(m_commonUi->fixedPosition, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedPosition(int))); connect(m_commonUi->fixedRotation, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedRotation(int))); connect(m_commonUi->fixedPerspective, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedPerspective(int))); connect(m_commonUi->newFrame, SIGNAL(clicked()), this, SLOT(slotAddFrame())); connect(m_commonUi->removeFrame, SIGNAL(clicked()), this, SLOT(slotRemoveFrame())); connect(m_commonUi->lookApplyAll, SIGNAL(clicked()), this, SLOT(slotLookApplyAll())); connect(m_commonUi->framesList, SIGNAL(itemSelectionChanged()), this, SLOT(slotFrameSelectionChanged())); connect(m_commonUi->reflection, SIGNAL(toggled(bool)), this, SLOT(slotReflectionToggled(bool))); // ITEM setup #if !defined(MOBILE_UI) setFlag(QGraphicsItem::ItemIgnoresTransformations, true); setWidget(widget); static qreal s_propZBase = 99999; setZValue(s_propZBase++); #endif #if !defined(MOBILE_UI) && QT_VERSION >= 0x040600 // fade in animation QPropertyAnimation * ani = new QPropertyAnimation(this, "opacity"); ani->setEasingCurve(QEasingCurve::OutCubic); ani->setDuration(400); ani->setStartValue(0.0); ani->setEndValue(1.0); ani->start(QPropertyAnimation::DeleteWhenStopped); #endif }
Akseli::Akseli(Vaunu *vaunu) : vaunu_(vaunu), toinenAkseli_(0), kytkettyAkseli_(0), kiskolla_(0), sijaintiKiskolla_(0), suuntaKiskolla_(RaiteenPaa::Virhe) { setZValue(200); // debug: jotta nähdään missä akseli on... }
void RelationItem::update(const Style *style) { QPointF endBPos = calcEndPoint(m_relation->endBUid(), m_relation->endAUid(), m_relation->intermediatePoints().size() - 1); QPointF endAPos = calcEndPoint(m_relation->endAUid(), endBPos, 0); setPos(endAPos); QList<QPointF> points; points << (endAPos - endAPos); foreach (const DRelation::IntermediatePoint &point, m_relation->intermediatePoints()) { points << (point.pos() - endAPos); } points << (endBPos - endAPos); ArrowConfigurator visitor(m_diagramSceneModel, m_arrow, points); m_relation->accept(&visitor); m_arrow->update(style); if (!m_relation->name().isEmpty()) { if (!m_name) { m_name = new QGraphicsSimpleTextItem(this); } m_name->setFont(style->smallFont()); m_name->setBrush(style->textBrush()); m_name->setText(m_relation->name()); m_name->setPos(m_arrow->calcPointAtPercent(0.5) + QPointF(-m_name->boundingRect().width() * 0.5, 4.0)); } else if (m_name) { m_name->scene()->removeItem(m_name); delete m_name; m_name = 0; } if (!m_relation->stereotypes().isEmpty()) { if (!m_stereotypes) { m_stereotypes = new StereotypesItem(this); } m_stereotypes->setFont(style->smallFont()); m_stereotypes->setBrush(style->textBrush()); m_stereotypes->setStereotypes(m_relation->stereotypes()); m_stereotypes->setPos(m_arrow->calcPointAtPercent(0.5) + QPointF(-m_stereotypes->boundingRect().width() * 0.5, -m_stereotypes->boundingRect().height() - 4.0)); } else if (m_stereotypes) { m_stereotypes->scene()->removeItem(m_stereotypes); delete m_stereotypes; m_stereotypes = 0; } if (isSelected() || isSecondarySelected()) { if (!m_selectionHandles) { m_selectionHandles = new PathSelectionItem(this, this); } m_selectionHandles->setPoints(points); m_selectionHandles->setSecondarySelected(isSelected() ? false : isSecondarySelected()); } else if (m_selectionHandles) { if (m_selectionHandles->scene()) { m_selectionHandles->scene()->removeItem(m_selectionHandles); } delete m_selectionHandles; m_selectionHandles = 0; } setZValue((isSelected() || isSecondarySelected()) ? RELATION_ITEMS_ZVALUE_SELECTED : RELATION_ITEMS_ZVALUE); }
void ContentWindowGraphicsItem::setZToFront() { zCounter_ = zCounter_ + 1; setZValue(zCounter_); }
void AbstractCardItem::setRealZValue(qreal _zValue) { realZValue = _zValue; setZValue(_zValue); }
QgsMapCanvasMap::QgsMapCanvasMap( QgsMapCanvas* canvas ) : QgsMapCanvasItem( canvas ) { setZValue( -10 ); }
/** * Constructs a NodeWidget. * * @param scene The parent of this NodeWidget. * @param n The UMLNode this will be representing. */ NodeWidget::NodeWidget(UMLScene * scene, UMLNode *n) : UMLWidget(scene, WidgetBase::wt_Node, n) { setSize(100, 30); setZValue(1); // above box but below UMLWidget because may embed widgets }
SceneWidgetCloseButton::SceneWidgetCloseButton() { setZValue(zValue()+0.5); setFlag(ItemIsSelectable, false); }
GraphicsMidiInputItem::GraphicsMidiInputItem(QDomElement controlNode, const PixmapMap& pixmapMap) { // map a midi message to a m_inputMidiMessages.append(MidiMessage(controlNode)); m_name = controlNode.attribute(CONTROL_NAME, ""); m_groupName = controlNode.attribute(CONTROL_GROUP, ""); QString debugColor = controlNode.attribute("debug"); GraphicsMidiArea area = parseAreaElement(controlNode); if (area.isNull()) return; QString mask = parsePixmapMask(controlNode); setSceneRect(area.rect); bool hasRanged = false; // get states QDomElement stateNode = controlNode.firstChildElement("state"); int rangeMarker; QPixmap backgroundPixmap = pixmapFromMap(GuiUtils::background, m_sceneRect, pixmapMap, mask); ushort minRangeId, maxRangeId; while (!stateNode.isNull()) { QString state = stateNode.text(); QString stateValue = stateNode.attribute("value").trimmed(); // map range to m_state2Pixmap rangeMarker = stateValue.indexOf(INPUT_STATE_RANGEMARKER); if (rangeMarker > 0) { hasRanged = true; bool ok = false; //qDebug() << state << stateValue << rangeMarker << stateValue.left(rangeMarker) << stateValue.mid(rangeMarker + 1); minRangeId = stateValue.left(rangeMarker).toUShort(&ok, 0); if (ok) maxRangeId = stateValue.mid(rangeMarker + 1).toUShort(&ok, 0); if (!ok) { qCritical() << "error parsing:" << stateValue << "; line:" << stateNode.lineNumber(); return; } QPixmap pixmap = pixmapFromState(stateNode, backgroundPixmap, m_sceneRect, pixmapMap, mask); if (!pixmap.isNull()) { checkDebug(debugColor, pixmap, area); // map range to m_state2Pixmap m_state2Pixmap.insert(maxRangeId, pixmap); m_range2State.insert(minRangeId, maxRangeId); // add ranged value } } else { bool ok = false; ushort stateId = stateValue.toUShort(&ok, 0); if (pixmapMap.contains(state) && ok) { // QPixmap pixmap = pixmapMap.value(state).copy(rect); QPixmap pixmap = pixmapFromState(stateNode, backgroundPixmap, m_sceneRect, pixmapMap, mask); checkDebug(debugColor, pixmap, area); m_state2Pixmap.insert(stateId, pixmap); m_range2State.insert(stateId, stateId); // support for ranged values if (GuiUtils::isBackground(state)) { m_offState = stateId; setPixmap(pixmap); } } } stateNode = stateNode.nextSiblingElement("state"); } if (!hasRanged) m_range2State.clear(); // no ranged values after all... /* QPixmap pixmap = pixmapMap[GuiUtils::background]; if (0) { setPixmap(pixmap.copy(rect)); } else { QPixmap tmp = pixmap.copy(rect); QPainter dc(&tmp); dc.setPen(Qt::green); dc.drawRect(0,0,rect.width()-1, rect.height()-1); setPixmap(tmp); } */ setPos(m_sceneRect.topLeft()); setZValue(2); m_hasInput = true; }
//virtual QVariant AbstractGroupItem::itemChange(GraphicsItemChange change, const QVariant &value) { if (change == QGraphicsItem::ItemSelectedChange) { if (value.toBool()) setZValue(3); else setZValue(1); } CustomTrackScene *scene = NULL; if (change == ItemPositionChange && parentItem() == 0) { scene = projectScene(); } if (scene) { // calculate new position. if (scene->isZooming) { // For some reason, mouse wheel on selected itm sometimes triggered // a position change event corrupting timeline, so discard it return pos(); } // calculate new position. const int trackHeight = KdenliveSettings::trackheight(); QPointF start = sceneBoundingRect().topLeft(); QPointF newPos = value.toPointF(); int xpos = projectScene()->getSnapPointForPos((int)(start.x() + newPos.x() - pos().x()), KdenliveSettings::snaptopoints()); xpos = qMax(xpos, 0); ////qDebug()<<"GRP XPOS:"<<xpos<<", START:"<<start.x()<<",NEW:"<<newPos.x()<<"; SCENE:"<<scenePos().x()<<",POS:"<<pos().x(); newPos.setX((int)(pos().x() + xpos - (int) start.x())); QStringList lockedTracks = property("locked_tracks").toStringList(); int proposedTrack = trackForPos(property("y_absolute").toInt() + newPos.y()); // Check if top item is a clip or a transition int offset = 0; int topTrack = -1; QList<int> groupTracks; QList<QGraphicsItem *> children = childItems(); for (int i = 0; i < children.count(); ++i) { int currentTrack = 0; if (children.at(i)->type() == AVWidget || children.at(i)->type() == TransitionWidget) { currentTrack = static_cast <AbstractClipItem*> (children.at(i))->track(); if (!groupTracks.contains(currentTrack)) groupTracks.append(currentTrack); } else if (children.at(i)->type() == GroupWidget) { currentTrack = static_cast <AbstractGroupItem*> (children.at(i))->track(); } else continue; if (children.at(i)->type() == AVWidget) { if (topTrack == -1 || currentTrack >= topTrack) { offset = 0; topTrack = currentTrack; } } else if (children.at(i)->type() == TransitionWidget) { if (topTrack == -1 || currentTrack > topTrack) { offset = (int)(trackHeight / 3 * 2 - 1); topTrack = currentTrack; } } else if (children.at(i)->type() == GroupWidget) { QList<QGraphicsItem *> subchildren = children.at(i)->childItems(); bool clipGroup = false; for (int j = 0; j < subchildren.count(); ++j) { if (subchildren.at(j)->type() == AVWidget || subchildren.at(j)->type() == TransitionWidget) { int subTrack = static_cast <AbstractClipItem*> (subchildren.at(j))->track(); if (!groupTracks.contains(subTrack)) groupTracks.append(subTrack); clipGroup = true; } } if (clipGroup) { if (topTrack == -1 || currentTrack >= topTrack) { offset = 0; topTrack = currentTrack; } } else { if (topTrack == -1 || currentTrack > topTrack) { offset = (int)(trackHeight / 3 * 2 - 1); topTrack = currentTrack; } } } } // Check no clip in the group goes outside of existing tracks int maximumTrack = projectScene()->tracksCount(); int groupHeight = 0; for (int i = 0; i < groupTracks.count(); ++i) { int offset = groupTracks.at(i) - topTrack; if (offset > groupHeight) groupHeight = offset; } maximumTrack -= groupHeight; proposedTrack = qMin(proposedTrack, maximumTrack); proposedTrack = qMax(proposedTrack, groupTracks.count()); int groupOffset = proposedTrack - topTrack; if (!lockedTracks.isEmpty()) { for (int i = 0; i < groupTracks.count(); ++i) { if (lockedTracks.contains(QString::number(groupTracks.at(i) + groupOffset))) { return pos(); } } } newPos.setY(posForTrack(proposedTrack) + offset); //if (newPos == start) return start; /*if (newPos.x() < 0) { // If group goes below 0, adjust position to 0 return QPointF(pos().x() - start.x(), pos().y()); }*/ QList<QGraphicsItem*> collidingItems; QPainterPath shape; if (projectScene()->editMode() == NormalEdit) { shape = clipGroupShape(newPos - pos()); collidingItems = scene->items(shape, Qt::IntersectsItemShape); collidingItems.removeAll(this); for (int i = 0; i < children.count(); ++i) { if (children.at(i)->type() == GroupWidget) { QList<QGraphicsItem *> subchildren = children.at(i)->childItems(); for (int j = 0; j < subchildren.count(); ++j) { collidingItems.removeAll(subchildren.at(j)); } } collidingItems.removeAll(children.at(i)); } } if (!collidingItems.isEmpty()) { bool forwardMove = xpos > start.x(); int offset = 0; for (int i = 0; i < collidingItems.count(); ++i) { QGraphicsItem *collision = collidingItems.at(i); if (collision->type() == AVWidget) { // Collision if (newPos.y() != pos().y()) { // Track change results in collision, restore original position return pos(); } AbstractClipItem *item = static_cast <AbstractClipItem *>(collision); // Determine best pos QPainterPath clipPath; clipPath.addRect(item->sceneBoundingRect()); QPainterPath res = shape.intersected(clipPath); offset = qMax(offset, (int)(res.boundingRect().width() + 0.5)); } } if (offset > 0) { if (forwardMove) { newPos.setX(newPos.x() - offset); } else { newPos.setX(newPos.x() + offset); } // If there is still a collision after our position adjust, restore original pos collidingItems = scene->items(clipGroupShape(newPos - pos()), Qt::IntersectsItemShape); collidingItems.removeAll(this); for (int i = 0; i < children.count(); ++i) { if (children.at(i)->type() == GroupWidget) { QList<QGraphicsItem *> subchildren = children.at(i)->childItems(); for (int j = 0; j < subchildren.count(); ++j) { collidingItems.removeAll(subchildren.at(j)); } } collidingItems.removeAll(children.at(i)); } for (int i = 0; i < collidingItems.count(); ++i) if (collidingItems.at(i)->type() == AVWidget) return pos(); } } if (projectScene()->editMode() == NormalEdit) { shape = transitionGroupShape(newPos - pos()); collidingItems = scene->items(shape, Qt::IntersectsItemShape); collidingItems.removeAll(this); for (int i = 0; i < children.count(); ++i) { if (children.at(i)->type() == GroupWidget) { QList<QGraphicsItem *> subchildren = children.at(i)->childItems(); for (int j = 0; j < subchildren.count(); ++j) { collidingItems.removeAll(subchildren.at(j)); } } collidingItems.removeAll(children.at(i)); } } if (collidingItems.isEmpty()) return newPos; else { bool forwardMove = xpos > start.x(); int offset = 0; for (int i = 0; i < collidingItems.count(); ++i) { QGraphicsItem *collision = collidingItems.at(i); if (collision->type() == TransitionWidget) { // Collision if (newPos.y() != pos().y()) { // Track change results in collision, restore original position return pos(); } AbstractClipItem *item = static_cast <AbstractClipItem *>(collision); // Determine best pos QPainterPath clipPath; clipPath.addRect(item->sceneBoundingRect()); QPainterPath res = shape.intersected(clipPath); offset = qMax(offset, (int)(res.boundingRect().width() + 0.5)); } } if (offset > 0) { if (forwardMove) { newPos.setX(newPos.x() - offset); } else { newPos.setX(newPos.x() + offset); } // If there is still a collision after our position adjust, restore original pos collidingItems = scene->items(transitionGroupShape(newPos - pos()), Qt::IntersectsItemShape); for (int i = 0; i < children.count(); ++i) { collidingItems.removeAll(children.at(i)); } for (int i = 0; i < collidingItems.count(); ++i) if (collidingItems.at(i)->type() == TransitionWidget) return pos(); } } return newPos; } return QGraphicsItemGroup::itemChange(change, value); }
void GraphicsMovieItem::paintRect( QPainter* painter, const QStyleOptionGraphicsItem* option ) { QRectF drawRect; bool drawRound; // Disable the matrix transformations painter->setWorldMatrixEnabled( false ); painter->setRenderHint( QPainter::Antialiasing ); // Get the transformations required to map the text on the viewport QTransform viewPortTransform = Timeline::getInstance()->tracksView()->viewportTransform(); // Determine if a drawing optimization can be used if ( option->exposedRect.left() > AbstractGraphicsItem::RounderRectRadius && option->exposedRect.right() < boundingRect().right() - AbstractGraphicsItem::RounderRectRadius ) { // Optimized: paint only the exposed (horizontal) area drawRect = QRectF( option->exposedRect.left(), boundingRect().top(), option->exposedRect.right(), boundingRect().bottom() ); drawRound = false; } else { // Unoptimized: the item must be fully repaint drawRect = boundingRect(); drawRound = true; } // Do the transformation QRectF mapped = deviceTransform( viewPortTransform ).mapRect( drawRect ); QLinearGradient gradient( mapped.topLeft(), mapped.bottomLeft() ); gradient.setColorAt( 0, QColor::fromRgb( 78, 78, 78 ) ); gradient.setColorAt( 0.4, QColor::fromRgb( 72, 72, 72 ) ); gradient.setColorAt( 0.4, QColor::fromRgb( 50, 50, 50 ) ); gradient.setColorAt( 1, QColor::fromRgb( 45, 45, 45 ) ); painter->setPen( Qt::NoPen ); painter->setBrush( QBrush( gradient ) ); if ( drawRound ) painter->drawRoundedRect( mapped, AbstractGraphicsItem::RounderRectRadius, AbstractGraphicsItem::RounderRectRadius ); else painter->drawRect( mapped ); if ( itemColor().isValid() ) { QRectF mediaColorRect = mapped.adjusted( 3, 2, -3, -2 ); painter->setPen( QPen( itemColor(), 2 ) ); painter->drawLine( mediaColorRect.topLeft(), mediaColorRect.topRight() ); } if ( isSelected() ) { setZValue( zSelected() ); painter->setPen( Qt::yellow ); painter->setBrush( Qt::NoBrush ); mapped.adjust( 0, 0, 0, -1 ); if ( drawRound ) painter->drawRoundedRect( mapped, AbstractGraphicsItem::RounderRectRadius, AbstractGraphicsItem::RounderRectRadius); else painter->drawRect( mapped ); } else setZValue( zNotSelected() ); }
PdfFrameHandle::PdfFrameHandle (QGraphicsScene &scene, QGraphicsView &view, const QPointF &pointReference, int orientationFlags, PdfCropping &pdfCropping, int zValue) : m_pdfCropping (pdfCropping), m_orientationFlags (orientationFlags), m_disableEventsWhileMovingAutomatically (false), m_scene (scene), m_view (view) { const double SUBTLE_OPACITY = 0.2; // Advantages of using ItemIgnoresTransformations: // 1) handles do not get bigger or smaller depending on the size of the image // 2) handles never get ugly when zoomed in // 3) handles never get too tiny when zoomed out // Disadvantages of using ItemIgnoresTransformation: // 1) Resizing the preview window with ItemIgnoresTransformations moves the handles out of position // 2) More conversions back and forth between untransformed and transformed coordinates. This was the deal breaker since // the transformations were undocumented and ultimately too difficult // The solution is to have constant-size handles WITHOUT ItemIgnoresTransformations. This means resizing the window // also involves resizing the handles, but everything else is pretty easy // // ItemIgnoresTransformations flag must agree with the QGraphicsRectItem used for the frame box by PdfCropping setFlags (QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsScenePositionChanges); // Fill with nice color for better visibility. Note that the pen is disabled by overriding the paint method setBrush (QBrush (Qt::blue)); setVisible (true); setZValue (zValue); setOpacity (SUBTLE_OPACITY); setPos (pointReference); // Point position is handled in scene/view coordinates // Add to scene scene.addItem (this); QSize handleSize = m_pdfCropping.windowSize() / HANDLE_SIZE_AS_FRACTION_OF_WINDOW_SIZE; // Adjust positions of handles that are not at the top left so handles are laid out symmetrically QPointF pointPos = pointReference; if ((orientationFlags && PdfCropping::PDF_CROPPING_LEFT) != 0) { pointPos.setX (pointPos.x() - handleSize.width() / 2.0); } else if ((orientationFlags && PdfCropping::PDF_CROPPING_RIGHT) != 0) { pointPos.setX (pointPos.x() + handleSize.width() / 2.0); } if ((orientationFlags && PdfCropping::PDF_CROPPING_TOP) != 0) { pointPos.setY (pointPos.y() - handleSize.height() / 2.0); } else if ((orientationFlags && PdfCropping::PDF_CROPPING_BOTTOM) != 0) { pointPos.setY (pointPos.y() + handleSize.height() / 2.0); } // Start with geometry. Since point positions are handled in scene/view coordinates, we have to convert // to local coordinates for the rectangle QPointF topLeftLocal = mapFromScene (pointPos); setRect (QRectF (topLeftLocal, handleSize)); }
Widget_WarpControlPaint::Widget_WarpControlPaint() { boundRect.setCoords(0, 0, 0, 0); setZValue(1); setColorScheme(1); }
void PixmapItem::loadPixmap(QDomElement text ) { QDomNode node = text.firstChild(); qreal posX = 0; qreal posY = 0; qreal zValue = 0; while(!node.isNull()) { if(node.toElement().tagName() == "name") { name = node.toElement().text(); } if(node.toElement().tagName() == "source") { source = node.toElement().text().toInt(); } if(node.toElement().tagName() == "file") { file = node.toElement().text(); } if(node.toElement().tagName() == "posX") { posX = node.toElement().text().toInt(); } if(node.toElement().tagName() == "posY") { posY = node.toElement().text().toInt(); } if(node.toElement().tagName() == "zValue") { zValue = node.toElement().text().toFloat(); } if(node.toElement().tagName() == "width") { size.setWidth( node.toElement().text().toInt() ); } if(node.toElement().tagName() == "height") { size.setHeight(node.toElement().text().toInt()); } if(node.toElement().tagName() == "isLocked") { isLocked = node.toElement().text().toInt(); if(isLocked) { setFlag(QGraphicsItem::ItemIsMovable, false); } } node = node.nextSibling(); } setZValue(zValue); if(source==0) { QPixmap p(file); p = p.scaledToWidth(size.width(),Qt::SmoothTransformation); setPos(posX, posY); setPixmap(p); } else { setPos(posX, posY); QFile unknown(":/images/unknown.jpg"); if(unknown.open(QIODevice::ReadOnly)) { pictureBufferUnknown.setData(unknown.readAll()); setHoruxPixmap(pictureBufferUnknown.data()); } } }
ToolTipItem::ToolTipItem(QString txt, QGraphicsItem* parent) : QGraphicsTextItem(txt, parent) { setDefaultTextColor(Colors::base03); setZValue(10); }
ProcessorGraphicsItem::ProcessorGraphicsItem(Processor* processor) : ProcessorObserver() , LabelGraphicsItemObserver() , processor_(processor) , processorMeta_(nullptr) , progressItem_(nullptr) , statusItem_(nullptr) , linkItem_(nullptr) , highlight_(false) #if IVW_PROFILING , processCount_(0) , countLabel_(nullptr) , maxEvalTime_(0.0) , evalTime_(0.0) , totEvalTime_(0.0) #endif { setZValue(PROCESSORGRAPHICSITEM_DEPTH); setFlags(ItemIsMovable | ItemIsSelectable | ItemIsFocusable | ItemSendsGeometryChanges); setCacheMode(QGraphicsItem::DeviceCoordinateCache); setRect(-width / 2, -height / 2, width, height); QGraphicsDropShadowEffect* processorShadowEffect = new QGraphicsDropShadowEffect(); processorShadowEffect->setOffset(3.0); processorShadowEffect->setBlurRadius(3.0); setGraphicsEffect(processorShadowEffect); nameLabel_ = new LabelGraphicsItem(this); nameLabel_->setCrop(9, 8); nameLabel_->setPos(-width / 2.0 + labelHeight, -height / 2.0 + 0.6 * labelHeight); nameLabel_->setDefaultTextColor(Qt::white); QFont nameFont("Segoe", labelHeight, QFont::Black, false); nameFont.setPixelSize(pointSizeToPixelSize(labelHeight)); nameLabel_->setFont(nameFont); LabelGraphicsItemObserver::addObservation(nameLabel_); classLabel_ = new LabelGraphicsItem(this); classLabel_->setCrop(9, 8); classLabel_->setPos(-width / 2.0 + labelHeight, -height / 2.0 + labelHeight * 2.0); classLabel_->setDefaultTextColor(Qt::lightGray); QFont classFont("Segoe", labelHeight, QFont::Normal, true); classFont.setPixelSize(pointSizeToPixelSize(labelHeight)); classLabel_->setFont(classFont); nameLabel_->setText(QString::fromStdString(processor_->getIdentifier())); classLabel_->setText(QString::fromStdString(processor_->getDisplayName() + " " + processor_->getTags().getString())); processor_->ProcessorObservable::addObserver(this); processorMeta_ = processor->getMetaData<ProcessorMetaData>(ProcessorMetaData::CLASS_IDENTIFIER); processorMeta_->addObserver(this); linkItem_ = new ProcessorLinkGraphicsItem(this); std::vector<Inport*> inports = processor_->getInports(); std::vector<Outport*> outports = processor_->getOutports(); inportX = rect().left() + 12.5f; inportY = rect().top() + 4.5f; outportX = rect().left() + 12.5f; outportY = rect().bottom() - 4.5f; for (auto& inport : inports) { addInport(inport); } for (auto& outport : outports) { addOutport(outport); } statusItem_ = new ProcessorStatusGraphicsItem(this, processor_); if (auto progressBarOwner = dynamic_cast<ProgressBarOwner*>(processor_)) { progressItem_ = new ProcessorProgressGraphicsItem(this, &(progressBarOwner->getProgressBar())); progressBarOwner->getProgressBar().ActivityIndicator::addObserver(statusItem_); } if (auto activityInd = dynamic_cast<ActivityIndicatorOwner*>(processor_)){ activityInd->getActivityIndicator().addObserver(statusItem_); } #if IVW_PROFILING countLabel_ = new LabelGraphicsItem(this); countLabel_->setCrop(9,8); countLabel_->setPos(rect().left() + labelHeight, height / 2 - labelHeight*2.5); countLabel_->setDefaultTextColor(Qt::lightGray); countLabel_->setFont(classFont); countLabel_->setTextWidth(width - 2*labelHeight); #endif setVisible(processorMeta_->isVisible()); setSelected(processorMeta_->isSelected()); setPos(QPointF(processorMeta_->getPosition().x, processorMeta_->getPosition().y)); }
void Item::setItemZValue(int zValue) { mZValue = zValue; setZValue(zValue); }
bool QgsComposerItem::_readXML( const QDomElement& itemElem, const QDomDocument& doc ) { Q_UNUSED( doc ); if ( itemElem.isNull() ) { return false; } //rotation mRotation = itemElem.attribute( "rotation", "0" ).toDouble(); //id mId = itemElem.attribute( "id", "" ); //frame QString frame = itemElem.attribute( "frame" ); if ( frame.compare( "true", Qt::CaseInsensitive ) == 0 ) { mFrame = true; } else { mFrame = false; } //position lock for mouse moves/resizes QString positionLock = itemElem.attribute( "positionLock" ); if ( positionLock.compare( "true", Qt::CaseInsensitive ) == 0 ) { mItemPositionLocked = true; } else { mItemPositionLocked = false; } //position double x, y, width, height; bool xOk, yOk, widthOk, heightOk; x = itemElem.attribute( "x" ).toDouble( &xOk ); y = itemElem.attribute( "y" ).toDouble( &yOk ); width = itemElem.attribute( "width" ).toDouble( &widthOk ); height = itemElem.attribute( "height" ).toDouble( &heightOk ); if ( !xOk || !yOk || !widthOk || !heightOk ) { return false; } mLastValidViewScaleFactor = itemElem.attribute( "lastValidViewScaleFactor", "-1" ).toDouble(); setSceneRect( QRectF( x, y, width, height ) ); setZValue( itemElem.attribute( "zValue" ).toDouble() ); //pen QDomNodeList frameColorList = itemElem.elementsByTagName( "FrameColor" ); if ( frameColorList.size() > 0 ) { QDomElement frameColorElem = frameColorList.at( 0 ).toElement(); bool redOk, greenOk, blueOk, alphaOk, widthOk; int penRed, penGreen, penBlue, penAlpha; double penWidth; penWidth = itemElem.attribute( "outlineWidth" ).toDouble( &widthOk ); penRed = frameColorElem.attribute( "red" ).toDouble( &redOk ); penGreen = frameColorElem.attribute( "green" ).toDouble( &greenOk ); penBlue = frameColorElem.attribute( "blue" ).toDouble( &blueOk ); penAlpha = frameColorElem.attribute( "alpha" ).toDouble( &alphaOk ); if ( redOk && greenOk && blueOk && alphaOk && widthOk ) { QPen framePen( QColor( penRed, penGreen, penBlue, penAlpha ) ); framePen.setWidthF( penWidth ); setPen( framePen ); } } //brush QDomNodeList bgColorList = itemElem.elementsByTagName( "BackgroundColor" ); if ( bgColorList.size() > 0 ) { QDomElement bgColorElem = bgColorList.at( 0 ).toElement(); bool redOk, greenOk, blueOk, alphaOk; int bgRed, bgGreen, bgBlue, bgAlpha; bgRed = bgColorElem.attribute( "red" ).toDouble( &redOk ); bgGreen = bgColorElem.attribute( "green" ).toDouble( &greenOk ); bgBlue = bgColorElem.attribute( "blue" ).toDouble( &blueOk ); bgAlpha = bgColorElem.attribute( "alpha" ).toDouble( &alphaOk ); if ( redOk && greenOk && blueOk && alphaOk ) { QColor brushColor( bgRed, bgGreen, bgBlue, bgAlpha ); setBrush( QBrush( brushColor ) ); } } return true; }
bool QgsComposerItem::_readXML( const QDomElement& itemElem, const QDomDocument& doc ) { Q_UNUSED( doc ); if ( itemElem.isNull() ) { return false; } //rotation setItemRotation( itemElem.attribute( "itemRotation", "0" ).toDouble() ); //uuid mUuid = itemElem.attribute( "uuid", QUuid::createUuid().toString() ); // temporary for groups imported from templates mTemplateUuid = itemElem.attribute( "templateUuid" ); //id QString id = itemElem.attribute( "id", "" ); setId( id ); //frame QString frame = itemElem.attribute( "frame" ); if ( frame.compare( "true", Qt::CaseInsensitive ) == 0 ) { mFrame = true; } else { mFrame = false; } //frame QString background = itemElem.attribute( "background" ); if ( background.compare( "true", Qt::CaseInsensitive ) == 0 ) { mBackground = true; } else { mBackground = false; } //position lock for mouse moves/resizes QString positionLock = itemElem.attribute( "positionLock" ); if ( positionLock.compare( "true", Qt::CaseInsensitive ) == 0 ) { setPositionLock( true ); } else { setPositionLock( false ); } //position int page; double x, y, pagex, pagey, width, height; bool xOk, yOk, pageOk, pagexOk, pageyOk, widthOk, heightOk, positionModeOK; x = itemElem.attribute( "x" ).toDouble( &xOk ); y = itemElem.attribute( "y" ).toDouble( &yOk ); page = itemElem.attribute( "page" ).toInt( &pageOk ); pagex = itemElem.attribute( "pagex" ).toDouble( &pagexOk ); pagey = itemElem.attribute( "pagey" ).toDouble( &pageyOk ); width = itemElem.attribute( "width" ).toDouble( &widthOk ); height = itemElem.attribute( "height" ).toDouble( &heightOk ); mLastUsedPositionMode = ( ItemPositionMode )itemElem.attribute( "positionMode" ).toInt( &positionModeOK ); if ( !positionModeOK ) { mLastUsedPositionMode = UpperLeft; } if ( pageOk && pagexOk && pageyOk ) { xOk = true; yOk = true; x = pagex; y = ( page - 1 ) * ( mComposition->paperHeight() + composition()->spaceBetweenPages() ) + pagey; } if ( !xOk || !yOk || !widthOk || !heightOk ) { return false; } mLastValidViewScaleFactor = itemElem.attribute( "lastValidViewScaleFactor", "-1" ).toDouble(); setSceneRect( QRectF( x, y, width, height ) ); setZValue( itemElem.attribute( "zValue" ).toDouble() ); //pen QDomNodeList frameColorList = itemElem.elementsByTagName( "FrameColor" ); if ( frameColorList.size() > 0 ) { QDomElement frameColorElem = frameColorList.at( 0 ).toElement(); bool redOk, greenOk, blueOk, alphaOk, widthOk; int penRed, penGreen, penBlue, penAlpha; double penWidth; penWidth = itemElem.attribute( "outlineWidth" ).toDouble( &widthOk ); penRed = frameColorElem.attribute( "red" ).toDouble( &redOk ); penGreen = frameColorElem.attribute( "green" ).toDouble( &greenOk ); penBlue = frameColorElem.attribute( "blue" ).toDouble( &blueOk ); penAlpha = frameColorElem.attribute( "alpha" ).toDouble( &alphaOk ); mFrameJoinStyle = QgsSymbolLayerV2Utils::decodePenJoinStyle( itemElem.attribute( "frameJoinStyle", "miter" ) ); if ( redOk && greenOk && blueOk && alphaOk && widthOk ) { QPen framePen( QColor( penRed, penGreen, penBlue, penAlpha ) ); framePen.setWidthF( penWidth ); framePen.setJoinStyle( mFrameJoinStyle ); setPen( framePen ); } } //brush QDomNodeList bgColorList = itemElem.elementsByTagName( "BackgroundColor" ); if ( bgColorList.size() > 0 ) { QDomElement bgColorElem = bgColorList.at( 0 ).toElement(); bool redOk, greenOk, blueOk, alphaOk; int bgRed, bgGreen, bgBlue, bgAlpha; bgRed = bgColorElem.attribute( "red" ).toDouble( &redOk ); bgGreen = bgColorElem.attribute( "green" ).toDouble( &greenOk ); bgBlue = bgColorElem.attribute( "blue" ).toDouble( &blueOk ); bgAlpha = bgColorElem.attribute( "alpha" ).toDouble( &alphaOk ); if ( redOk && greenOk && blueOk && alphaOk ) { QColor brushColor( bgRed, bgGreen, bgBlue, bgAlpha ); setBackgroundColor( brushColor ); } } //blend mode setBlendMode( QgsMapRenderer::getCompositionMode(( QgsMapRenderer::BlendMode ) itemElem.attribute( "blendMode", "0" ).toUInt() ) ); //transparency setTransparency( itemElem.attribute( "transparency" , "0" ).toInt() ); return true; }
void GMWMarker::calculatePixmap() { // qDebug() << "calculating pixmap for:" << d->m_item->name(); bool booked = false; int timeLeft; if(d->m_item->objectType() == GMWItem::TypeVehicle) { GMWVehicle *vehicle = qobject_cast<GMWVehicle*>(d->m_item); if(vehicle->booking()->isValid()) { booked = true; timeLeft = vehicle->booking()->timeLeft(); } } if (d->m_highlight || booked) { QPixmap pixmap = d->m_item->imageL(); if(booked) { qDebug() << "car is booked:" << d->m_item->name(); QImage image = pixmap.toImage(); QPainter painter(&image); QPixmap overlay; #ifdef MEEGO if(timeLeft > 900) { overlay = QPixmap("/usr/share/themes/blanco/meegotouch/icons/icon-s-common-presence-online.png"); } else if(timeLeft > 0){ overlay = QPixmap("/usr/share/themes/blanco/meegotouch/icons/icon-s-common-presence-away.png"); } else { overlay = QPixmap("/usr/share/themes/blanco/meegotouch/icons/icon-s-common-presence-busy.png"); } #elif defined Q_WS_S60 if(timeLeft > 900) { overlay = QPixmap("qml/symbian/images/bookingstate_green_s.png"); } else if(timeLeft > 0){ overlay = QPixmap("qml/symbian/images/bookingstate_yellow_s.png"); } else { overlay = QPixmap("qml/symbian/images/bookingstate_red_s.png"); } #endif painter.drawPixmap(image.width() - overlay.width() - 5, 5, overlay); pixmap = QPixmap::fromImage(image); } setPixmap(pixmap); setOffset(QPoint(-pixmap.width()/2, -pixmap.height())); setZValue(1); } else { setPixmap(d->m_item->image()); setOffset(QPoint(-pixmap().width()/2, -pixmap().height())); setZValue(0); } if(d->m_count > 1 && !booked) { QImage image = pixmap().toImage(); QPainter painter(&image); QPixmap overlay = QPixmap(":qml/getmewheels2/harmattan/images/squircle_s_gray.png"); painter.drawPixmap(image.width() - overlay.width(), 0, overlay); QPen pen(Qt::white); painter.setPen(pen); QFont font = painter.font(); font.setPixelSize(14); painter.setFont(font); painter.drawText(image.width() - 13, 14, QString::number(d->m_count)); setPixmap(QPixmap::fromImage(image)); } }
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, bool _revealZone, bool _writeableRevealZone, const QList<const ServerInfo_Card *> &cardList) : QGraphicsWidget(0, Qt::Tool | Qt::FramelessWindowHint), player(_player) { setAcceptHoverEvents(true); setAttribute(Qt::WA_DeleteOnClose); setZValue(2000000006); setFlag(ItemIgnoresTransformations); QGraphicsLinearLayout *hbox = new QGraphicsLinearLayout(Qt::Horizontal); titleLabel = new TitleLabel; connect(titleLabel, SIGNAL(mouseMoved(QPointF)), this, SLOT(moveWidget(QPointF))); closeButton = new QPushButton("X"); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QGraphicsProxyWidget *closeButtonProxy = new QGraphicsProxyWidget; closeButtonProxy->setWidget(closeButton); hbox->addItem(titleLabel); hbox->addItem(closeButtonProxy); QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical); vbox->addItem(hbox); if (numberCards < 0) { QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget; sortByNameProxy->setWidget(&sortByNameCheckBox); vbox->addItem(sortByNameProxy); QGraphicsProxyWidget *sortByTypeProxy = new QGraphicsProxyWidget; sortByTypeProxy->setWidget(&sortByTypeCheckBox); vbox->addItem(sortByTypeProxy); QGraphicsProxyWidget *lineProxy = new QGraphicsProxyWidget; QFrame *line = new QFrame; line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); lineProxy->setWidget(line); vbox->addItem(lineProxy); QGraphicsProxyWidget *pileViewProxy = new QGraphicsProxyWidget; pileViewProxy->setWidget(&pileViewCheckBox); vbox->addItem(pileViewProxy); } if (_origZone->getIsShufflable() && (numberCards == -1)) { shuffleCheckBox.setChecked(settingsCache->getZoneViewShuffle()); QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget; shuffleProxy->setWidget(&shuffleCheckBox); vbox->addItem(shuffleProxy); } extraHeight = vbox->sizeHint(Qt::PreferredSize).height(); resize(150, 150); QGraphicsLinearLayout *zoneHBox = new QGraphicsLinearLayout(Qt::Horizontal); zoneContainer = new QGraphicsWidget(this); zoneContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); zoneContainer->setFlag(QGraphicsItem::ItemClipsChildrenToShape); zoneHBox->addItem(zoneContainer); scrollBar = new QScrollBar(Qt::Vertical); scrollBar->setMinimum(0); scrollBar->setSingleStep(50); connect(scrollBar, SIGNAL(valueChanged(int)), this, SLOT(handleScrollBarChange(int))); QGraphicsProxyWidget *scrollBarProxy = new QGraphicsProxyWidget; scrollBarProxy->setWidget(scrollBar); zoneHBox->addItem(scrollBarProxy); vbox->addItem(zoneHBox); zone = new ZoneViewZone(player, _origZone, numberCards, _revealZone, _writeableRevealZone, zoneContainer); connect(zone, SIGNAL(wheelEventReceived(QGraphicsSceneWheelEvent *)), this, SLOT(handleWheelEvent(QGraphicsSceneWheelEvent *))); // numberCard is the num of cards we want to reveal from an area. Ex: scry the top 3 cards. // If the number is < 0 then it means that we can make the area sorted and we dont care about the order. if (numberCards < 0) { connect(&sortByNameCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSortByName(int))); connect(&sortByTypeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSortByType(int))); connect(&pileViewCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSetPileView(int))); sortByNameCheckBox.setChecked(settingsCache->getZoneViewSortByName()); sortByTypeCheckBox.setChecked(settingsCache->getZoneViewSortByType()); pileViewCheckBox.setChecked(settingsCache->getZoneViewPileView()); if (!settingsCache->getZoneViewSortByType()) pileViewCheckBox.setEnabled(false); }
BGI_AirWire::BGI_AirWire(BI_AirWire& airwire) noexcept : BGI_Base(), mAirWire(airwire), mLayer(nullptr) { mLayer = getLayer(GraphicsLayer::sBoardAirWires); setZValue(Board::ZValue_AirWires); updateCacheAndRepaint(); }
Grid::Grid(int size, QGraphicsItem * parent) : QGraphicsItem(parent), m_size(size) { setZValue(s_gridZVlaue); }
//! [6] void ImageItem::updateItemPosition() { setZValue(z); }
void QgsPaperItem::initialize() { setFlag( QGraphicsItem::ItemIsSelectable, false ); setFlag( QGraphicsItem::ItemIsMovable, false ); setZValue( 0 ); }
CustomItemEllipse::CustomItemEllipse() { ellipse = boundingRect(); setFlag(ItemIsMovable); setZValue(10); }
QgsComposerItemGroup::QgsComposerItemGroup( QgsComposition* c ): QgsComposerItem( c ) { setZValue( 90 ); show(); }
OriginIndicator(QGraphicsItem *parent = 0) : Handle(parent) { setFlag(QGraphicsItem::ItemIsMovable); setZValue(10000 + 1); }
Label::Label() { m_sName = ""; setFlag(QGraphicsItem::ItemIsSelectable); setZValue(2); }
void DiagramWindow::sendToBack() { --minZ; setZValue(minZ); }