void Selection::mousePressEvent(QMouseEvent *event) { QWidget::mousePressEvent(event); QApplication::setOverrideCursor(Qt::CrossCursor); switch (st) { case NO_SELECTION: break; case RECTANGULAR_SELECTION: tl = br = event->pos(); sr = QRect(tl, br); break; case CUSTOM_SHAPE_SELECTION: path = QPainterPath(); path.moveTo(event->pos()); break; } isSelecting = true; update(); }
void Spacer::layout0() { qreal _spatium = spatium(); path = QPainterPath(); qreal w = _spatium; qreal b = w * .5; qreal h = _gap; switch (spacerType()) { case SpacerType::DOWN: path.lineTo(w, 0.0); path.moveTo(b, 0.0); path.lineTo(b, h); path.lineTo(0.0, h-b); path.moveTo(b, h); path.lineTo(w, h-b); break; case SpacerType::UP: path.moveTo(b, 0.0); path.lineTo(0.0, b); path.moveTo(b, 0.0); path.lineTo(w, b); path.moveTo(b, 0.0); path.lineTo(b, h); path.moveTo(0.0, h); path.lineTo(w, h); break; case SpacerType::FIXED: path.lineTo(w, 0.0); path.moveTo(b, 0.0); path.lineTo(b, h); path.moveTo(0.0, h); path.lineTo(w, h); break; } qreal lw = _spatium * 0.4; QRectF bb(0, 0, w, h); bb.adjust(-lw, -lw, lw, lw); setbbox(bb); }
QPainterPath Toolbox::shapeFromPath(const QPainterPath& path, const QPen& pen, const QBrush& brush, const UnsignedLength& minWidth) noexcept { // http://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/graphicsview/qgraphicsitem.cpp // Function: qt_graphicsItem_shapeFromPath() if (path == QPainterPath() || pen == Qt::NoPen) { return path; } else { QPainterPathStroker ps; ps.setCapStyle(pen.capStyle()); ps.setWidth(qMax(qMax(pen.widthF(), qreal(0.00000001)), minWidth->toPx())); ps.setJoinStyle(pen.joinStyle()); ps.setMiterLimit(pen.miterLimit()); QPainterPath p = ps.createStroke(path); if (brush != Qt::NoBrush) { p.addPath(path); } return p; } }
QPainterPath ArrowItem::shape() const { QPainterPath path; path.setFillRule(Qt::WindingFill); if (m_shaftItem &&m_shaftItem->path() != QPainterPath()) { QPainterPathStroker ps; QPen pen = m_shaftItem->pen(); ps.setCapStyle(pen.capStyle()); ps.setJoinStyle(pen.joinStyle()); ps.setMiterLimit(pen.miterLimit()); // overwrite pen width to make selection more lazy ps.setWidth(16.0); QPainterPath p = ps.createStroke(m_shaftItem->path()); path.addPath(p); } if (m_startHeadItem) path.addRect(mapRectFromItem(m_startHeadItem, m_startHeadItem->boundingRect())); if (m_endHeadItem) path.addRect(mapRectFromItem(m_endHeadItem, m_endHeadItem->boundingRect())); return path; }
QPolygon RescaleWidget:: recreatePolygon () { QPoint o = rect().center(); QPoint x = scalex_ * (rect().topRight() - rect().topLeft())/4; QPoint y = scaley_ * (rect().bottomLeft() - rect().topLeft())/4; QPolygon poly; float d = 0.3; float r = 0.1; poly.push_back( o - r*x - r*y); poly.push_back( o - d*x - y); poly.push_back( o + d*x - y); poly.push_back( o + r*x - r*y); poly.push_back( o - d*y + x); poly.push_back( o + d*y + x); poly.push_back( o + r*x + r*y); poly.push_back( o + d*x + y); poly.push_back( o - d*x + y); poly.push_back( o - r*x + r*y); poly.push_back( o + d*y - x); poly.push_back( o - d*y - x); if ( 0 == "push a circle" ) { float N = max(width(), height()); for (float i=0; i<N; ++i) { float a = 2*M_PI*(i/N); poly.push_back(o + x*cos(a) + y*sin(a)); } } path_ = QPainterPath(); path_.addPolygon(poly); update(); return poly; }
void UserMarkerItem::updateFullText() { prepareGeometryChange(); if(_text2.isEmpty() || !m_showSubtext) _fulltext = _text1; else _fulltext = _text1 + "\n[" + _text2 + ']'; // Make a new bubble for the text QRect textrect = qApp->fontMetrics().boundingRect(QRect(0, 0, 0xffff, 0xffff), 0, _fulltext); const float round = 3; const float padding = 5; const float width = qMax((ARROW+round)*2, textrect.width() + 2*padding); const float rad = width / 2.0; const float height = textrect.height() + ARROW + 2 * padding; _bounds = QRectF(-rad, -height, width, height); _textrect = _bounds.adjusted(padding, padding, -padding, -padding); _bubble = QPainterPath(QPointF(0, 0)); _bubble.lineTo(-ARROW, -ARROW); _bubble.lineTo(-rad+round, -ARROW); _bubble.quadTo(-rad, -ARROW, -rad, -ARROW-round); _bubble.lineTo(-rad, -height+round); _bubble.quadTo(-rad, -height, -rad+round, -height); _bubble.lineTo(rad-round, -height); _bubble.quadTo(rad, -height, rad, -height+round); _bubble.lineTo(rad, -ARROW-round); _bubble.quadTo(rad, -ARROW, rad-round, -ARROW); _bubble.lineTo(ARROW, -ARROW); _bubble.closeSubpath(); }
void ER_ItemRelationship::adjustNameSize() { defaultLength = WIDTH_LENGTH; dynamicLength = componentName.length() * WORD_LENGTH; // 依name大小調整邊框寬度 pointVector.clear(); pointVector.push_back(QPointF(defaultLength + dynamicLength, 0)); pointVector.push_back(QPointF(0, -defaultLength)); pointVector.push_back(QPointF(-(defaultLength + dynamicLength), 0)); pointVector.push_back(QPointF(0, defaultLength)); pointVector.push_back(QPointF(defaultLength + dynamicLength, 0)); componentPainterPath = QPainterPath(); componentPainterPath.addPolygon(QPolygonF(pointVector)); componentPen.setColor(Qt::black); componentPen.setWidth(PEN_WIDTH); originalConnectionPoint.clear(); originalConnectionPoint.push_back(QPointF(0, defaultLength - FOUR)); originalConnectionPoint.push_back(QPointF(defaultLength + dynamicLength - FOUR, 0)); originalConnectionPoint.push_back(QPointF(0, -(defaultLength - FOUR))); originalConnectionPoint.push_back(QPointF(-(defaultLength + dynamicLength - FOUR), 0)); }
void SelectionStrategy::leftButtonPressEvent(int i, int j) { if (selection.contains(i*BLOCSIZE,j*BLOCSIZE)) // move the selection { deb = selection.topLeft().toPoint() - QPoint(i*BLOCSIZE,j*BLOCSIZE); inMove=true; selectionOff(); if (selection==initSelection) clearZoneSelected(); blitTileSelectLayer(); } else //strt a new selection { blitTileSelected(); mapView->setSelectionArea(QPainterPath()); selection.setLeft(i*BLOCSIZE); selection.setTop(j*BLOCSIZE); selection.setWidth(BLOCSIZE); selection.setHeight(BLOCSIZE); itemRectSelected->setRect(selection); } }
LinkBox::LinkBox(Route *route, MachineBox *m1, MachineBox *m2) { this->m1 = m1; this->m2 = m2; this->route = route; setAcceptHoverEvents(true); setFlag(QGraphicsItem::ItemIsFocusable, true); backgrounds << QColor(0x00, 0x00, 0x00) << QColor(0x80, 0x80, 0x80); setBrush(QBrush(backgrounds[0])); setCursor(Qt::PointingHandCursor); basePath = QPainterPath(QPointF(10, 0)); basePath.lineTo(-5, -10); basePath.lineTo(-5, 10); basePath.closeSubpath(); px = py = 0; repos(); }
void drawBackgroundAndNumbers( QPainter* painter, const QString& text, const QRect& figRectIn ) { painter->save(); QRect figRect = figRectIn; if ( text.length() == 1 ) figRect.adjust( -painter->fontMetrics().averageCharWidth(), 0, 0, 0 ); QPen origpen = painter->pen(); QPen pen = origpen; pen.setWidth( 1.0 ); painter->setPen( pen ); painter->drawRect( figRect ); // circles look bad. make it an oval. (thanks, apple) const int bulgeWidth = 8; const int offset = 0; // number of pixels to begin, counting inwards from figRect.x() and figRect.width(). 0 means start at each end, negative means start inside the rect. QPainterPath ppath; ppath.moveTo( QPoint( figRect.x() + offset, figRect.y() + figRect.height() / 2 ) ); QRect leftArcRect( figRect.x() + offset - bulgeWidth, figRect.y(), 2*bulgeWidth, figRect.height() ); ppath.arcTo( leftArcRect, 90, 180 ); painter->drawPath( ppath ); ppath = QPainterPath(); ppath.moveTo( figRect.x() + figRect.width() - offset, figRect.y() + figRect.height() / 2 ); leftArcRect = QRect( figRect.x() + figRect.width() - offset - bulgeWidth, figRect.y(), 2*bulgeWidth, figRect.height() ); ppath.arcTo( leftArcRect, 270, 180 ); painter->drawPath( ppath ); figRect.adjust( -1, 0, 0, 0 ); painter->setPen( origpen ); painter->setPen( Qt::white ); painter->drawText( figRect.adjusted( -5, 0, 6, 0 ), text, QTextOption( Qt::AlignCenter ) ); painter->restore(); }
QPainterPath DiagonalWipeStrategy::clipPath( int step, const QRect &area ) { qreal percent = static_cast<qreal>(step) / static_cast<qreal>(StepCount); QPoint vecx( static_cast<int>(2.0 * area.width() * percent), 0 ) ; QPoint vecy( 0, static_cast<int>( 2.0 * area.height() * percent ) ); QPainterPath path; switch( subType() ) { case DiagonalWipeEffectFactory::FromTopLeft: path.moveTo( area.topLeft() ); path.lineTo( area.topLeft() + vecx ); path.lineTo( area.topLeft() + vecy ); break; case DiagonalWipeEffectFactory::FromTopRight: path.moveTo( area.topRight() ); path.lineTo( area.topRight() - vecx ); path.lineTo( area.topRight() + vecy ); break; case DiagonalWipeEffectFactory::FromBottomLeft: path.moveTo( area.bottomLeft() ); path.lineTo( area.bottomLeft() + vecx ); path.lineTo( area.bottomLeft() - vecy ); break; case DiagonalWipeEffectFactory::FromBottomRight: path.moveTo( area.bottomRight() ); path.lineTo( area.bottomRight() - vecx ); path.lineTo( area.bottomRight() - vecy ); break; default: return QPainterPath(); } path.closeSubpath(); return path; }
void Context2D::reset() { m_stateStack.clear(); m_state.matrix = QMatrix(); m_state.clipPath = QPainterPath(); m_state.globalAlpha = 1.0; m_state.globalCompositeOperation = QPainter::CompositionMode_SourceOver; m_state.strokeStyle = Qt::black; m_state.fillStyle = Qt::black; m_state.lineWidth = 1; m_state.lineCap = Qt::FlatCap; m_state.lineJoin = Qt::MiterJoin; m_state.miterLimit = 10; m_state.shadowOffsetX = 0; m_state.shadowOffsetY = 0; m_state.shadowBlur = 0; m_state.shadowColor = qRgba(0, 0, 0, 0); m_state.flags = AllIsFullOfDirt; m_state.textAlign = Start; m_state.textBaseline = Alphabetic; clear(); }
void SCgPathItem::updatePath() { QPainterPath path; if (mPoints.isEmpty()) { mPath.setPath(QPainterPath()); return; } path.moveTo(mPoints.first()); for (int idx = 1; idx != mPoints.size(); ++idx) path.lineTo(mPoints.at(idx)); //Draw path in parent coordinates if (mPath.parentItem()) path = mPath.parentItem()->mapFromScene(path); // mPath->setPen(mPen); mPath.setPath(path); }
void RepeatMeasure::layout() { qreal sp = spatium(); qreal y = sp; qreal w = sp * 2.0; qreal h = sp * 2.0; qreal lw = sp * .30; // line width qreal r = sp * .15; // dot radius path = QPainterPath(); path.moveTo(w - lw, y); path.lineTo(w, y); path.lineTo(lw, h+y); path.lineTo(0.0, h+y); path.closeSubpath(); path.addEllipse(QRectF(w * .25 - r, y+h * .25 - r, r * 2.0, r * 2.0 )); path.addEllipse(QRectF(w * .75 - r, y+h * .75 - r, r * 2.0, r * 2.0 )); setbbox(path.boundingRect()); }
static QPainterPath qwtBorderPath( const QWidget *canvas, const QRect &rect ) { if ( canvas->testAttribute(Qt::WA_StyledBackground ) ) { QwtStyleSheetRecorder recorder( rect.size() ); QPainter painter( &recorder ); QStyleOption opt; opt.initFrom( canvas ); opt.rect = rect; canvas->style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, canvas ); painter.end(); if ( !recorder.background.path.isEmpty() ) return recorder.background.path; if ( !recorder.border.rectList.isEmpty() ) return qwtCombinePathList( rect, recorder.border.pathList ); } else { const double borderRadius = canvas->property( "borderRadius" ).toDouble(); if ( borderRadius > 0.0 ) { double fw2 = canvas->property( "frameWidth" ).toInt() * 0.5; QRectF r = QRectF(rect).adjusted( fw2, fw2, -fw2, -fw2 ); QPainterPath path; path.addRoundedRect( r, borderRadius, borderRadius ); return path; } } return QPainterPath(); }
void GraphicsContext::fillRect(const FloatRect& rect) { if (paintingDisabled()) return; QPainter *p = m_data->p(); switch (m_common->state.fillColorSpace) { case SolidColorSpace: if (fillColor().alpha()) p->fillRect(rect, p->brush()); break; case PatternColorSpace: { TransformationMatrix affine; p->fillRect(rect, QBrush(m_common->state.fillPattern->createPlatformPattern(affine))); break; } case GradientColorSpace: p->fillRect(rect, QBrush(*(m_common->state.fillGradient.get()->platformGradient()))); break; } m_data->currentPath = QPainterPath(); }
void file_save_pic (const QString &filename, QGraphicsView *view, bool isdraft) { const int border = 25; QRectF rect = view->scene()->itemsBoundingRect(); QRect prect = rect.adjusted(-border,-border,border,border).toRect(); QPixmap pixmap(prect.size()); pixmap.fill(Qt::white); QPainter paintr(&pixmap); paintr.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); view->scene()->setSelectionArea(QPainterPath()); view->scene()->render( &paintr, pixmap.rect(), rect.toRect().adjusted(-border,-border,border,border) ); if (isdraft) { paintr.setFont(QFont("Verdana", 20, QFont::Bold, true)); paintr.drawText(border+2,border+2,QObject::tr("DRAFT")); } paintr.end(); pixmap.save(filename, "PNG"); }
void UBGraphicsFreehandItem::copyItemParameters(UBItem *copy) const { UBGraphicsFreehandItem *cp = dynamic_cast<UBGraphicsFreehandItem*>(copy); if (cp) { cp->setPath(QPainterPath(this->path())); cp->setTransform(this->transform()); cp->setFlag(QGraphicsItem::ItemIsMovable, true); cp->setFlag(QGraphicsItem::ItemIsSelectable, true); cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); cp->setData(UBGraphicsItemData::ItemLocked, this->data(UBGraphicsItemData::ItemLocked)); if(Delegate()->action()){ if(Delegate()->action()->linkType() == eLinkToAudio){ UBGraphicsItemPlayAudioAction* audioAction = dynamic_cast<UBGraphicsItemPlayAudioAction*>(Delegate()->action()); UBGraphicsItemPlayAudioAction* action = new UBGraphicsItemPlayAudioAction(audioAction->fullPath()); cp->Delegate()->setAction(action); } else cp->Delegate()->setAction(Delegate()->action()); } } }
void Note::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(widget); if (m_hidden) return; if (m_inactive) { painter->save(); painter->setOpacity(InactiveOpacity); } painter->setPen(m_pen); painter->setBrush(m_brush); painter->drawRect(m_rect); if (option->state & QStyle::State_Selected) { GraphicsUtils::qt_graphicsItem_highlightSelected(painter, option, boundingRect(), QPainterPath()); } if (m_inactive) { painter->restore(); } }
void ChordLine::setSubtype(ChordLineType st) { qreal x2 = 0; qreal y2 = 0; switch(st) { case CHORDLINE_NOTYPE: break; case CHORDLINE_FALL: x2 = 2; y2 = 2; break; default: case CHORDLINE_DOIT: x2 = 2; y2 = -2; break; } if (st) { path = QPainterPath(); path.cubicTo(x2/2, 0.0, x2, y2/2, x2, y2); } _subtype = st; }
void PaintArea::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { if (!pendingPath.isEmpty()) { QPainter painter(&theImage); setupPainter(painter); const QRectF boundingRect = pendingPath.boundingRect(); QLinearGradient gradient(boundingRect.topRight(),boundingRect.bottomLeft()); gradient.setColorAt(0.0, QColor(color.red(), color.green(),color.blue(), 63)); gradient.setColorAt(1.0, QColor(color.red(), color.green(),color.blue(), 191)); painter.setBrush(gradient); painter.translate(event->pos() - boundingRect.center()); painter.drawPath(pendingPath); pendingPath = QPainterPath(); #ifndef QT_NO_CURSOR unsetCursor(); #endif update(); } else { if (brushInterface) { QPainter painter(&theImage); setupPainter(painter); const QRect rect = brushInterface->mousePress(brush, painter, event->pos()); update(rect); } lastPos = event->pos(); } } }
void PHIContext2D::reset() { _stateStack.clear(); _state.matrix=QMatrix(); _state.clipPath=QPainterPath(); _state.globalAlpha=1.0; _state.globalCompositeOperation=QPainter::CompositionMode_SourceOver; _state.strokeStyle=Qt::black; _state.fillStyle=Qt::black; _state.lineWidth=1; _state.lineCap=Qt::FlatCap; _state.lineJoin=Qt::MiterJoin; _state.miterLimit=10; _state.shadowOffsetX=0; _state.shadowOffsetY=0; _state.shadowBlur=0; _state.shadowColor=qRgba( 0, 0, 0, 0 ); _state.textAlign=1; // "start" _state.textBaseline=1; // "alphabetic" _state.font=QFont( QStringLiteral( "Helvetica" ) ); _state.font.setPixelSize( 10 ); _state.flags=AllIsFullOfDirt; clear(); }
void ChordLine::setChordLineType(ChordLineType st) { qreal x2 = 0; qreal y2 = 0; switch(st) { case CHORDLINE_NOTYPE: break; case CHORDLINE_FALL: x2 = 2; y2 = 2; break; case CHORDLINE_PLOP: x2 = -2; y2 = -2; break; case CHORDLINE_SCOOP: x2 = -2; y2 = 2; break; default: case CHORDLINE_DOIT: x2 = 2; y2 = -2; break; } if (st) { path = QPainterPath(); // chordlines to the right of the note if (st == CHORDLINE_FALL || st == CHORDLINE_DOIT) path.cubicTo(x2/2, 0.0, x2, y2/2, x2, y2); // chordlines to the left of the note if (st == CHORDLINE_PLOP || st == CHORDLINE_SCOOP) path.cubicTo(0.0, y2/2, x2/2, y2, x2, y2); } _chordLineType = st; }
QList<QPainterPath> Path_Builder::build() { if ( strokes.empty() ) return QList<QPainterPath>(); QList<QPainterPath> paths; foreach ( const container::value_type& ll, strokes ) { if ( ll.empty() ) continue; paths.push_back(QPainterPath()); QPointF nextpoint = ll[0]->begin; paths.back().moveTo(nextpoint); foreach ( path_item::Line* stroke, ll ) { stroke->add_to(true,paths.back()); nextpoint = stroke->end; } }
void GNode::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { QPen pen = m_pen; QBrush brush = m_brush; QPainterPath m_path = QPainterPath(); QRectF bRect = m_textItem->boundingRect(); bRect.setCoords(0, 0,m_size + 2 * m_xmargin, m_size + 2 * m_ymargin); m_path.addRoundedRect(bRect, m_cornerRadius, m_cornerRadius, Qt::SizeMode::AbsoluteSize); if (option->state & QStyle::State_Selected) { pen = s_selectedPen; brush = s_selectedBrush; } painter->setPen(pen); painter->setBrush(brush); painter->drawPath(m_path); if (option->state & QStyle::State_Selected) { GDefaultSelectionGraphic::paint(bRect, painter); } }
/** * Reimplemented from UMLWidget::attributeChange to handle @ref * SizeHasChanged to position the texts as well as build the painter * path corresponding to current size. */ QVariant NodeWidget::attributeChange(WidgetAttributeChange change, const QVariant& oldValue) { if(change == SizeHasChanged) { TextItemGroup *grp = textItemGroupAt(GroupIndex); m_nodeWidgetPath = QPainterPath(); // reset path const qreal w = size().width(); const qreal h = size().height(); const qreal wDepth = qMin(w/3, NodeWidget::DEPTH); const qreal hDepth = qMin(h/3, NodeWidget::DEPTH); const qreal bodyOffsetY = hDepth; const qreal bodyWidth = w - wDepth; const qreal bodyHeight = h - hDepth; QPolygonF poly; poly << QPointF(0, bodyOffsetY) << QPointF(wDepth, 0) << QPointF(w - 1, 0) << QPointF(w - 1, bodyHeight) << QPointF(bodyWidth, h - 1) << QPointF(bodyWidth, bodyOffsetY) << QPointF(0, bodyOffsetY); m_nodeWidgetPath.addPolygon(poly); QRectF bodyRect(0, bodyOffsetY, bodyWidth, bodyHeight); m_nodeWidgetPath.addRect(bodyRect); QLineF line(w - 1, 0, bodyWidth - 2, bodyOffsetY + 1); m_nodeWidgetPath.moveTo(line.p1()); m_nodeWidgetPath.lineTo(line.p2()); grp->setGroupGeometry(bodyRect); } return UMLWidget::attributeChange(change, oldValue); }
void UploadAnimation::paintFrame(Painter &p, style::color color, int x, int y, int outerWidth, int frameMs) { PainterHighQualityEnabler hq(p); auto pen = color->p; pen.setWidth(st::historySendActionUploadStrokeNumerator / st::historySendActionUploadDenominator); pen.setJoinStyle(Qt::RoundJoin); pen.setCapStyle(Qt::RoundCap); p.setPen(pen); p.setBrush(Qt::NoBrush); auto progress = frameMs / float64(st::historySendActionUploadDuration); auto position = QPointF(x + st::historySendActionUploadDelta * progress, y) + st::historySendActionUploadPosition; auto path = QPainterPath(); path.moveTo(0., -st::historySendActionUploadSizeNumerator / st::historySendActionUploadDenominator); path.lineTo(st::historySendActionUploadSizeNumerator / st::historySendActionUploadDenominator, 0.); path.lineTo(0., st::historySendActionUploadSizeNumerator / st::historySendActionUploadDenominator); p.translate(position); for (auto i = 0; i != kUploadArrowsCount; ++i) { p.setOpacity((i == 0) ? progress : (i == kUploadArrowsCount - 1) ? (1. - progress) : 1.); p.drawPath(path); position.setX(position.x() + st::historySendActionUploadDelta); p.translate(st::historySendActionUploadDelta, 0); } p.setOpacity(1.); p.translate(-position); }
void PencilTool::smoothPath(QPainterPath &path, double smoothness, int from, int to) { QPolygonF polygon; QList<QPolygonF> polygons = path.toSubpathPolygons(); QList<QPolygonF>::iterator it = polygons.begin(); QPolygonF::iterator pointIt; while (it != polygons.end()) { pointIt = (*it).begin(); while (pointIt <= (*it).end()-2) { polygon << (*pointIt); pointIt += 2; } ++it; } if (smoothness > 0) { path = TupGraphicalAlgorithm::bezierFit(polygon, smoothness, from, to); } else { path = QPainterPath(); path.addPolygon(polygon); } }
SCEyeWipeEffectFactory::SCEyeWipeEffectFactory() : SCPageEffectFactory(EyeWipeEffectId, i18n("Eye")) { QPainterPath shape; //vertical shape.moveTo(0, -12); shape.quadTo(10, 0, 0, 12); shape.quadTo(-10, 0, 0, -12); addStrategy(new SCIrisWipeEffectStrategyBase(shape, Vertical, "eyeWipe", "vertical", false)); //vertical reverse addStrategy(new SCIrisWipeEffectStrategyBase(shape, VerticalReverse, "eyeWipe", "vertical", true)); //horizontal shape = QPainterPath(); shape.moveTo(-12, 0); shape.quadTo(0, 10, 12, 0); shape.quadTo(0, -10, -12, 0); addStrategy(new SCIrisWipeEffectStrategyBase(shape, Horizontal, "eyeWipe", "horizontal", false)); //horizontal reverse addStrategy(new SCIrisWipeEffectStrategyBase(shape, HorizontalReverse, "eyeWipe", "horizontal", true)); }
void PAData::paintToScene(QGraphicsScene &scene, QGraphicsItemGroup *group) { CODEBOOK *ts = static_cast<CODEBOOK*>(this->associatedData.data()->getData()); PARTITIONING *pa = &this->partition; CONVEXHULLSET *hull = NULL; ConstructConvexHulls(ts, pa, &hull); QGraphicsItem *item = NULL; CONVEXVERTEX* CV; for (int index=0; index < CHS_size(hull); index++ ) { CV = CHS_hullfirst(hull, index); if(!CV) continue; QPointF start_point = QPointF(VectorScalar(ts, CV->index, 0), VectorScalar(ts, CV->index, 1)); QPainterPath path = QPainterPath(start_point); CV = CV_next(CV); while( CV != NULL ) { QPointF point = QPointF(VectorScalar(ts, CV->index, 0), VectorScalar(ts, CV->index, 1)); path.lineTo(point); CV = CV_next(CV); } item = new QGraphicsPathItem(path); if (group) group->addToGroup(item); else scene.addItem(item); } if (hull != NULL) FreeConvexHulls(hull); }