mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-12-24 16:38:34 -07:00
Make sure undo stroke properly clears all the set pixels
CURA-12752 Otherwise, when merging the polygons and undo-ing the whole stroke, there may be some remaining pixels outside the mesh triangles that would not be cleared, because the rasterizing is not 100% identical
This commit is contained in:
parent
06a7592483
commit
33671083cd
3 changed files with 8 additions and 7 deletions
|
|
@ -42,6 +42,6 @@ class PaintClearCommand(PaintCommand):
|
|||
# There is actually nothing more to do here, both clear commands already have the same original texture
|
||||
return True
|
||||
|
||||
def _clearTextureBits(self, painter: QPainter):
|
||||
def _clearTextureBits(self, painter: QPainter, extended = False):
|
||||
painter.setCompositionMode(QPainter.CompositionMode.RasterOp_NotSourceAndDestination)
|
||||
painter.fillRect(self._texture.getImage().rect(), QBrush(self._getBitRangeMask()))
|
||||
|
|
@ -43,7 +43,7 @@ class PaintCommand(QUndoCommand):
|
|||
if self._original_texture_image is None:
|
||||
return
|
||||
|
||||
painter = self._makeClearedTexture()
|
||||
painter = self._makeClearedTexture(extended=True)
|
||||
painter.setCompositionMode(QPainter.CompositionMode.RasterOp_SourceOrDestination)
|
||||
painter.drawImage(0, 0, self._original_texture_image)
|
||||
painter.end()
|
||||
|
|
@ -55,14 +55,14 @@ class PaintCommand(QUndoCommand):
|
|||
if self._sliceable_object_decorator is not None:
|
||||
self._sliceable_object_decorator.setPaintedExtrudersCountDirty()
|
||||
|
||||
def _makeClearedTexture(self) -> QPainter:
|
||||
def _makeClearedTexture(self, extended = False) -> QPainter:
|
||||
painter = QPainter(self._texture.getImage())
|
||||
painter.setRenderHint(QPainter.RenderHint.Antialiasing, False)
|
||||
|
||||
self._clearTextureBits(painter)
|
||||
self._clearTextureBits(painter, extended)
|
||||
return painter
|
||||
|
||||
def _clearTextureBits(self, painter: QPainter):
|
||||
def _clearTextureBits(self, painter: QPainter, extended = False):
|
||||
raise NotImplementedError()
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class PaintStrokeCommand(PaintCommand):
|
|||
"""Provides the command that does the actual painting on objects with undo/redo mechanisms"""
|
||||
|
||||
PEN_OVERLAP_WIDTH = 2.5
|
||||
PEN_OVERLAP_WIDTH_EXTENDED = PEN_OVERLAP_WIDTH + 0.5
|
||||
|
||||
def __init__(self,
|
||||
texture: Texture,
|
||||
|
|
@ -58,9 +59,9 @@ class PaintStrokeCommand(PaintCommand):
|
|||
|
||||
return True
|
||||
|
||||
def _clearTextureBits(self, painter: QPainter):
|
||||
def _clearTextureBits(self, painter: QPainter, extended = False):
|
||||
painter.setBrush(QBrush(self._getBitRangeMask()))
|
||||
painter.setPen(QPen(painter.brush(), self.PEN_OVERLAP_WIDTH))
|
||||
painter.setPen(QPen(painter.brush(), self.PEN_OVERLAP_WIDTH_EXTENDED if extended else self.PEN_OVERLAP_WIDTH))
|
||||
painter.setCompositionMode(QPainter.CompositionMode.RasterOp_NotSourceAndDestination)
|
||||
painter.drawPath(self._makePainterPath())
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue