Commit 3795ef34 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Let the paintOp's stay as they were when the canvas became mirrored

BUG:310684
parent 486a6177
......@@ -177,7 +177,11 @@ void KisPaintOpSettings::setCanvasRotation(qreal angle)
setPropertyNotSaved("runtimeCanvasRotation");
}
qreal KisPaintOpSettings::canvasRotation() const
void KisPaintOpSettings::setCanvasMirroring(bool xAxisMirrored, bool yAxisMirrored)
{
return getDouble("runtimeCanvasRotation");
setProperty("runtimeCanvasMirroredX", xAxisMirrored);
setPropertyNotSaved("runtimeCanvasMirroredX");
setProperty("runtimeCanvasMirroredY", yAxisMirrored);
setPropertyNotSaved("runtimeCanvasMirroredY");
}
......@@ -171,8 +171,14 @@ public:
/// @return loadable state of the settings, by default implementation return the same as isValid()
virtual bool isLoadable();
/**
* These methods are populating properties with runtime
* information about canvas rotation/mirroring. This information
* is set directly by KisToolFreehand. Later the data is accessed
* by the pressure options to make a final decision.
*/
void setCanvasRotation(qreal angle);
qreal canvasRotation() const;
void setCanvasMirroring(bool xAxisMirrored, bool yAxisMirrored);
protected:
/**
......
......@@ -68,33 +68,29 @@ void KisPressureMirrorOption::readOptionSetting(const KisPropertiesConfiguration
KisCurveOption::readOptionSetting(setting);
m_enableHorizontalMirror = setting->getBool(MIRROR_HORIZONTAL_ENABLED,false);
m_enableVerticalMirror = setting->getBool(MIRROR_VERTICAL_ENABLED, false);
m_canvasAxisXMirrored = setting->getBool("runtimeCanvasMirroredX", false);
m_canvasAxisYMirrored = setting->getBool("runtimeCanvasMirroredY", false);
}
MirrorProperties KisPressureMirrorOption::apply(const KisPaintInformation& info) const
{
MirrorProperties mirrors;
if ((!m_enableHorizontalMirror && !m_enableVerticalMirror) || (!isChecked())){
mirrors.horizontalMirror = false;
mirrors.verticalMirror = false;
return mirrors;
}
double sensorResult = computeValue(info);
bool result = (sensorResult >= 0.5);
if (m_enableHorizontalMirror){
mirrors.horizontalMirror = result;
}else{
mirrors.horizontalMirror = false;
}
if (m_enableVerticalMirror){
mirrors.verticalMirror = result;
}else{
mirrors.verticalMirror = false;
int mirrorXIncrement = m_canvasAxisXMirrored;
int mirrorYIncrement = m_canvasAxisYMirrored;
if (isChecked() && (m_enableHorizontalMirror || m_enableVerticalMirror)){
qreal sensorResult = computeValue(info);
bool result = (sensorResult >= 0.5);
mirrorXIncrement += result && m_enableHorizontalMirror;
mirrorYIncrement += result && m_enableVerticalMirror;
}
MirrorProperties mirrors;
mirrors.verticalMirror = mirrorXIncrement % 2;
mirrors.horizontalMirror = mirrorYIncrement % 2;
return mirrors;
}
......
......@@ -58,6 +58,8 @@ public:
private:
bool m_enableVerticalMirror;
bool m_enableHorizontalMirror;
bool m_canvasAxisXMirrored;
bool m_canvasAxisYMirrored;
};
#endif
......@@ -232,6 +232,16 @@ QPoint KisCoordinatesConverter::mirror(QPointF center, bool mirrorXAxis, bool mi
return m_d->documentOffset.toPoint();
}
bool KisCoordinatesConverter::xAxisMirrored() const
{
return m_d->isXAxisMirrored;
}
bool KisCoordinatesConverter::yAxisMirrored() const
{
return m_d->isYAxisMirrored;
}
QPoint KisCoordinatesConverter::resetRotation(QPointF center)
{
QTransform rot;
......
......@@ -68,6 +68,8 @@ public:
QPoint rotate(QPointF center, qreal angle);
QPoint mirror(QPointF center, bool mirrorXAxis, bool mirrorYAxis, bool keepOrientation=false);
bool xAxisMirrored() const;
bool yAxisMirrored() const;
QPoint resetRotation(QPointF center);
virtual void setZoom(qreal zoom);
......
......@@ -230,7 +230,10 @@ void KisToolFreehand::mousePressEvent(KoPointerEvent *e)
canvas2->view()->disableControls();
currentPaintOpPreset()->settings()->setCanvasRotation( static_cast<KisCanvas2*>(canvas())->rotationAngle() );
const KisCoordinatesConverter *converter = static_cast<KisCanvas2*>(canvas())->coordinatesConverter();
currentPaintOpPreset()->settings()->setCanvasRotation(converter->rotationAngle());
currentPaintOpPreset()->settings()->setCanvasMirroring(converter->xAxisMirrored(),
converter->yAxisMirrored());
initStroke(e);
e->accept();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment