Am 07.10.2007 um 20:35 schrieb Andre Poenitz:

On Sun, Oct 07, 2007 at 07:23:56PM +0200, Stefan Schimanski wrote:
Hi!

For my dynamic macros I need an extension to the Painter for
monochrome rendering. This is independent of my other patch, so I
post it here first:

Basically all colors are mapped into an interval [min,max] of two
colors. By this subformulas can be greyed out easily without touching
the inset at all. All the needed logic is in
GuiPainter::enterMonochromeMode and GuiPainter::leaveMonochromeMode
and the GuiPainter::computeColor/filterColor methods.

Objections? Improvements?

Maybe a bit longer explanation?

Sure. On enterMonochromeMode you pass a min and a max color. Every drawing command sets the QPen color before it does the real drawing. But in monochrome mode the color is first converted into greyscale and then mapped into the interval [min,max]. So "white" will be mapped to min, a half blue color will be between min and max somewhere, and black will go to max. This gives a grey scale effect.

The two colors min and max are stored in the monochrome_min_/max_ stacks. If the stack are empty we are in polychrome (the normal) mode. So the enterMonochromeMode pushes the colors onto the stacks, the leave function pops them.

The length of the patch mainlys come from the fact that I changed the type in the setQPainterPen method to get a QColor, instead of Color_color. This is needed for the pixmap cache logic because it has no proper monochrome color stacks in the temporary GuiPainter it uses.

Hope this makes it more clear.

Stefan

Attachment: PGP.sig
Description: Signierter Teil der Nachricht

Reply via email to