本文整理汇总了C++中KisPaintInformation类的典型用法代码示例。如果您正苦于以下问题:C++ KisPaintInformation类的具体用法?C++ KisPaintInformation怎么用?C++ KisPaintInformation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KisPaintInformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintLine
KisDistanceInformation KisCurvePaintOp::paintLine(const KisPaintInformation& pi1, const KisPaintInformation& pi2, const KisDistanceInformation& savedDist)
{
Q_UNUSED(savedDist);
if (!painter()) return KisDistanceInformation();
m_dev = painter()->device();
if (!m_dev) return KisDistanceInformation();
if (!m_dab) {
m_dab = new KisPaintDevice(painter()->device()->colorSpace());
} else {
m_dab->clear();
}
//write device, read device, position
m_curveBrush.paintLine(m_dab, m_dev, pi1, pi2);
QRect rc = m_dab->extent();
painter()->bitBlt(rc.topLeft(), m_dab, rc);
KisVector2D end = toKisVector2D(pi2.pos());
KisVector2D start = toKisVector2D(pi1.pos());
KisVector2D dragVec = end - start;
return KisDistanceInformation(0, dragVec.norm());
}
示例2: sqrt
void KisToolFreehandHelper::stabilizerPollAndPaint()
{
KisStabilizedEventsSampler::iterator it;
KisStabilizedEventsSampler::iterator end;
std::tie(it, end) = m_d->stabilizedSampler.range();
QVector<KisPaintInformation> delayedPaintTodoItems;
for (; it != end; ++it) {
KisPaintInformation sampledInfo = *it;
bool canPaint = true;
if (m_d->smoothingOptions->useDelayDistance()) {
const qreal R = m_d->smoothingOptions->delayDistance() /
m_d->resources->effectiveZoom();
QPointF diff = sampledInfo.pos() - m_d->previousPaintInformation.pos();
qreal dx = sqrt(pow2(diff.x()) + pow2(diff.y()));
canPaint = dx > R;
}
if (canPaint) {
KisPaintInformation newInfo =
m_d->getStabilizedPaintInfo(m_d->stabilizerDeque, sampledInfo);
if (m_d->stabilizerDelayedPaintHelper.running()) {
delayedPaintTodoItems.append(newInfo);
} else {
paintLine(m_d->previousPaintInformation, newInfo);
}
m_d->previousPaintInformation = newInfo;
// Push the new entry through the queue
m_d->stabilizerDeque.dequeue();
m_d->stabilizerDeque.enqueue(sampledInfo);
} else if (m_d->stabilizerDeque.head().pos() != m_d->previousPaintInformation.pos()) {
QQueue<KisPaintInformation>::iterator it = m_d->stabilizerDeque.begin();
QQueue<KisPaintInformation>::iterator end = m_d->stabilizerDeque.end();
while (it != end) {
*it = m_d->previousPaintInformation;
++it;
}
}
}
m_d->stabilizedSampler.clear();
if (m_d->stabilizerDelayedPaintHelper.running()) {
m_d->stabilizerDelayedPaintHelper.update(delayedPaintTodoItems);
} else {
emit requestExplicitUpdateOutline();
}
}
示例3: paintAt
KisSpacingInformation KisLiquifyPaintop::paintAt(const KisPaintInformation &pi)
{
static const qreal sizeToSigmaCoeff = 1.0 / 3.0;
const qreal size = sizeToSigmaCoeff *
(m_d->props.sizeHasPressure() ?
pi.pressure() * m_d->props.size():
m_d->props.size());
const qreal spacing = m_d->props.spacing() * size;
const qreal reverseCoeff =
m_d->props.mode() !=
KisLiquifyProperties::UNDO &&
m_d->props.reverseDirection() ? -1.0 : 1.0;
const qreal amount = m_d->props.amountHasPressure() ?
pi.pressure() * reverseCoeff * m_d->props.amount():
reverseCoeff * m_d->props.amount();
const bool useWashMode = m_d->props.useWashMode();
const qreal flow = m_d->props.flow();
switch (m_d->props.mode()) {
case KisLiquifyProperties::MOVE: {
const qreal offsetLength = size * amount;
m_d->worker->translatePoints(pi.pos(),
pi.drawingDirectionVector() * offsetLength,
size, useWashMode, flow);
break;
}
case KisLiquifyProperties::SCALE:
m_d->worker->scalePoints(pi.pos(),
amount,
size, useWashMode, flow);
break;
case KisLiquifyProperties::ROTATE:
m_d->worker->rotatePoints(pi.pos(),
2.0 * M_PI * amount,
size, useWashMode, flow);
break;
case KisLiquifyProperties::OFFSET: {
const qreal offsetLength = size * amount;
m_d->worker->translatePoints(pi.pos(),
KisAlgebra2D::rightUnitNormal(pi.drawingDirectionVector()) * offsetLength,
size, useWashMode, flow);
break;
}
case KisLiquifyProperties::UNDO:
m_d->worker->undoPoints(pi.pos(),
amount,
size);
break;
case KisLiquifyProperties::N_MODES:
qFatal("Not supported mode");
}
return KisSpacingInformation(spacing);
}
示例4: elapsedStrokeTime
void KisToolLineHelper::start(KoPointerEvent *event, KoCanvasResourceManager *resourceManager)
{
if (!m_d->enabled) return;
KisPaintInformation pi =
m_d->infoBuilder->startStroke(event, elapsedStrokeTime(), resourceManager);
if (!m_d->useSensors) {
pi = KisPaintInformation(pi.pos());
}
m_d->linePoints.append(pi);
}
示例5: brushOutline
QPainterPath KisDuplicateOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode)
{
QPainterPath path;
// clone tool should always show an outline
path = KisBrushBasedPaintOpSettings::brushOutlineImpl(info, mode, 1.0, true);
QPainterPath copy(path);
QRectF rect2 = copy.boundingRect();
if (m_isOffsetNotUptodate || !getBool(DUPLICATE_MOVE_SOURCE_POINT)) {
copy.translate(m_position - info.pos());
}
else {
copy.translate(-m_offset);
}
path.addPath(copy);
qreal dx = rect2.width() / 4.0;
qreal dy = rect2.height() / 4.0;
rect2.adjust(dx, dy, -dx, -dy);
path.moveTo(rect2.topLeft());
path.lineTo(rect2.bottomRight());
path.moveTo(rect2.topRight());
path.lineTo(rect2.bottomLeft());
return path;
}
示例6: paintAt
KisSpacingInformation KisChalkPaintOp::paintAt(const KisPaintInformation& info)
{
if (!painter()) return 1.0;
if (!m_dab) {
m_dab = source()->createCompositionSourceDevice();
} else {
m_dab->clear();
}
qreal x1, y1;
x1 = info.pos().x();
y1 = info.pos().y();
quint8 origOpacity = m_opacityOption.apply(painter(), info);
m_chalkBrush->paint(m_dab, x1, y1, painter()->paintColor());
QRect rc = m_dab->extent();
painter()->bitBlt(rc.x(), rc.y(), m_dab, rc.x(), rc.y(), rc.width(), rc.height());
painter()->renderMirrorMask(rc,m_dab);
painter()->setOpacity(origOpacity);
return 1.0;
}
示例7: getInt
QPainterPath KisGridPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
{
QPainterPath path;
if (mode == CursorIsOutline || mode == CursorIsCircleOutline || mode == CursorTiltOutline) {
qreal sizex = getInt(GRID_WIDTH) * getDouble(GRID_SCALE);
qreal sizey = getInt(GRID_HEIGHT) * getDouble(GRID_SCALE);
QRectF rc(0, 0, sizex, sizey);
rc.translate(-rc.center());
path.addRect(rc);
QPainterPath tiltLine;
QLineF tiltAngle(QPointF(0.0,0.0), QPointF(0.0,sizex));
tiltAngle.setLength(qMax(sizex*0.5, 50.0) * (1 - info.tiltElevation(info, 60.0, 60.0, true)));
tiltAngle.setAngle((360.0 - fmod(KisPaintInformation::tiltDirection(info, true) * 360.0 + 270.0, 360.0))-3.0);
tiltLine.moveTo(tiltAngle.p1());
tiltLine.lineTo(tiltAngle.p2());
tiltAngle.setAngle((360.0 - fmod(KisPaintInformation::tiltDirection(info, true) * 360.0 + 270.0, 360.0))+3.0);
tiltLine.lineTo(tiltAngle.p2());
tiltLine.lineTo(tiltAngle.p1());
path = outlineFetcher()->fetchOutline(info, this, path);
if (mode == CursorTiltOutline) {
path.addPath(outlineFetcher()->fetchOutline(info, this, tiltLine, 1.0, 0.0, true, 0, 0));
}
}
return path;
}
示例8: paintLine
void KisCurvePaintOp::paintLine(KisPaintDeviceSP dab, const KisPaintInformation &pi1, const KisPaintInformation &pi2)
{
if (!m_painter) {
m_painter = new KisPainter(dab);
m_painter->setPaintColor(painter()->paintColor());
}
int maxPoints = m_curveProperties.curve_stroke_history_size;
m_points.append(pi2.pos());
while (m_points.length() > maxPoints) {
m_points.removeFirst();
}
const qreal additionalScale = KisLodTransform::lodToScale(painter()->device());
const qreal lineWidth = additionalScale * m_lineWidthOption.apply(pi2, m_curveProperties.curve_line_width);
QPen pen(QBrush(Qt::white), lineWidth);
QPainterPath path;
if (m_curveProperties.curve_paint_connection_line) {
path.moveTo(pi1.pos());
path.lineTo(pi2.pos());
m_painter->drawPainterPath(path, pen);
path = QPainterPath();
}
if (m_points.length() >= maxPoints) {
// alpha * 0.2;
path.moveTo(m_points.first());
if (m_curveProperties.curve_smoothing) {
path.quadTo(m_points.at(maxPoints / 2), m_points.last());
}
else {
// control point is at 1/3 of the history, 2/3 of the history and endpoint at 3/3
int step = maxPoints / 3;
path.cubicTo(m_points.at(step), m_points.at(step + step), m_points.last());
}
qreal curveOpacity = m_curvesOpacityOption.apply(pi2, m_curveProperties.curve_curves_opacity);
m_painter->setOpacity(qRound(255.0 * curveOpacity));
m_painter->drawPainterPath(path, pen);
m_painter->setOpacity(255); // full
}
}
示例9: mousePressEvent
bool KisDuplicateOpSettings::mousePressEvent(const KisPaintInformation &info, Qt::KeyboardModifiers modifiers)
{
bool ignoreEvent = true;
if (modifiers == Qt::ControlModifier) {
m_position = info.pos();
m_isOffsetNotUptodate = true;
ignoreEvent = false;
} else {
if (m_isOffsetNotUptodate) {
m_offset = info.pos() - m_position;
m_isOffsetNotUptodate = false;
}
ignoreEvent = true;
}
return ignoreEvent;
}
示例10: brushOutline
QPainterPath KisLiquifyPaintop::brushOutline(const KisLiquifyProperties &props,
const KisPaintInformation &info)
{
const qreal diameter = props.size();
const qreal reverseCoeff = props.reverseDirection() ? -1.0 : 1.0;
QPainterPath outline;
outline.addEllipse(-0.5 * diameter, -0.5 * diameter,
diameter, diameter);
switch (props.mode()) {
case KisLiquifyProperties::MOVE:
case KisLiquifyProperties::SCALE:
break;
case KisLiquifyProperties::ROTATE: {
QPainterPath p;
p.lineTo(-3.0, 4.0);
p.moveTo(0.0, 0.0);
p.lineTo(-3.0, -4.0);
QTransform S;
if (diameter < 15.0) {
const qreal scale = diameter / 15.0;
S = QTransform::fromScale(scale, scale);
}
QTransform R;
R.rotateRadians(-reverseCoeff * 0.5 * M_PI);
QTransform T = QTransform::fromTranslate(0.5 * diameter, 0.0);
p = (S * R * T).map(p);
outline.addPath(p);
break;
}
case KisLiquifyProperties::OFFSET: {
qreal normalAngle = info.drawingAngle() + reverseCoeff * 0.5 * M_PI;
QPainterPath p = KisAlgebra2D::smallArrow();
const qreal offset = qMax(0.8 * diameter, 15.0);
QTransform R;
R.rotateRadians(normalAngle);
QTransform T = QTransform::fromTranslate(offset, 0.0);
p = (T * R).map(p);
outline.addPath(p);
break;
}
case KisLiquifyProperties::UNDO:
break;
case KisLiquifyProperties::N_MODES:
qFatal("Not supported mode");
}
return outline;
}
示例11: updateBrushMask
void KisSketchPaintOp::updateBrushMask(const KisPaintInformation& info, qreal scale, qreal rotation){
m_maskDab = m_dabCache->fetchDab(m_dab->colorSpace(), painter()->paintColor(), scale, scale,
rotation, info);
// update bounding box
m_brushBoundingBox = m_maskDab->bounds();
m_hotSpot = m_brush->hotSpot(scale,scale,rotation,info);
m_brushBoundingBox.translate(info.pos() - m_hotSpot);
}
示例12: paintBezierCurve
void KisToolFreehandHelper::paintBezierCurve(int painterInfoId,
const KisPaintInformation &pi1,
const QPointF &control1,
const QPointF &control2,
const KisPaintInformation &pi2)
{
#ifdef DEBUG_BEZIER_CURVES
KisPaintInformation tpi1;
KisPaintInformation tpi2;
tpi1 = pi1;
tpi2 = pi2;
tpi1.setPressure(0.3);
tpi2.setPressure(0.3);
paintLine(tpi1, tpi2);
tpi1.setPressure(0.6);
tpi2.setPressure(0.3);
tpi1.setPos(pi1.pos());
tpi2.setPos(control1);
paintLine(tpi1, tpi2);
tpi1.setPos(pi2.pos());
tpi2.setPos(control2);
paintLine(tpi1, tpi2);
#endif
m_d->hasPaintAtLeastOnce = true;
m_d->strokesFacade->addJob(m_d->strokeId,
new FreehandStrokeStrategy::Data(m_d->resources->currentNode(),
painterInfoId,
pi1, control1, control2, pi2));
if(m_d->recordingAdapter) {
m_d->recordingAdapter->addCurve(pi1, control1, control2, pi2);
}
}
示例13: mousePressEvent
bool KisDuplicateOpSettings::mousePressEvent(const KisPaintInformation &info, Qt::KeyboardModifiers modifiers, KisNodeWSP currentNode)
{
bool ignoreEvent = true;
if (modifiers & Qt::ControlModifier) {
if (!m_sourceNode || !(modifiers & Qt::AltModifier)) {
m_sourceNode = currentNode;
}
m_position = info.pos();
m_isOffsetNotUptodate = true;
ignoreEvent = false;
}
else {
if (m_isOffsetNotUptodate) {
m_offset = info.pos() - m_position;
m_isOffsetNotUptodate = false;
}
ignoreEvent = true;
}
return ignoreEvent;
}
示例14: updateBrushMask
void KisSketchPaintOp::updateBrushMask(const KisPaintInformation& info, qreal scale, qreal rotation)
{
QRect dstRect;
m_maskDab = m_dabCache->fetchDab(m_dab->colorSpace(),
painter()->paintColor(),
info.pos(),
scale, scale, rotation,
info, 1.0,
&dstRect);
m_brushBoundingBox = dstRect;
m_hotSpot = QPointF(0.5 * m_brushBoundingBox.width(),
0.5 * m_brushBoundingBox.height());
}
示例15: paintLine
void KisParticlePaintOp::paintLine(const KisPaintInformation &pi1, const KisPaintInformation &pi2, KisDistanceInformation *currentDistance)
{
Q_UNUSED(currentDistance);
if (!painter()) return;
if (!m_dab) {
m_dab = source()->createCompositionSourceDevice();
}
else {
m_dab->clear();
}
if (m_first) {
m_particleBrush.setInitialPosition(pi1.pos());
m_first = false;
}
m_particleBrush.draw(m_dab, painter()->paintColor(), pi2.pos());
QRect rc = m_dab->extent();
painter()->bitBlt(rc.x(), rc.y(), m_dab, rc.x(), rc.y(), rc.width(), rc.height());
painter()->renderMirrorMask(rc, m_dab);
}