From 52755383ede6842fd94222055ddaec6a962c92bc Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Thu, 5 Dec 2013 19:45:39 -0500 Subject: [PATCH] Sync graphics item with matrix and shadow common parameters. --- app/LabelModelBoxObject.cpp | 6 ++++++ app/LabelModelObject.cpp | 23 +++++++++++++++++++++++ app/LabelModelObject.h | 4 ++++ 3 files changed, 33 insertions(+) diff --git a/app/LabelModelBoxObject.cpp b/app/LabelModelBoxObject.cpp index a40d1b1..37dab7b 100644 --- a/app/LabelModelBoxObject.cpp +++ b/app/LabelModelBoxObject.cpp @@ -40,6 +40,9 @@ namespace glabels pen.setWidthF( lineWidth() ); rectItem->setPen( pen ); + updateGraphicsItemMatrix( rectItem ); + updateGraphicsItemShadow( rectItem ); + return rectItem; } @@ -58,6 +61,9 @@ namespace glabels QPen pen( lineColorNode().color() ); pen.setWidthF( lineWidth() ); rectItem->setPen( pen ); + + updateGraphicsItemMatrix( rectItem ); + updateGraphicsItemShadow( rectItem ); } } diff --git a/app/LabelModelObject.cpp b/app/LabelModelObject.cpp index d7bee0d..b64b9d6 100644 --- a/app/LabelModelObject.cpp +++ b/app/LabelModelObject.cpp @@ -20,6 +20,8 @@ #include "LabelModelObject.h" +#include + namespace glabels { @@ -178,5 +180,26 @@ namespace glabels emit changed(); } + + void LabelModelObject::updateGraphicsItemMatrix( QGraphicsItem* graphicsItem ) + { + graphicsItem->setTransform( mMatrix ); + } + + + void LabelModelObject::updateGraphicsItemShadow( QGraphicsItem* graphicsItem ) + { + QGraphicsDropShadowEffect *shadowEffect = new QGraphicsDropShadowEffect(); + + QColor color = mShadowColorNode.color(); + color.setAlphaF( mShadowOpacity ); + + shadowEffect->setColor( color ); + shadowEffect->setOffset( mShadowX, mShadowY ); + shadowEffect->setBlurRadius( 0 ); + + graphicsItem->setGraphicsEffect( shadowEffect ); + } + } diff --git a/app/LabelModelObject.h b/app/LabelModelObject.h index 9edaf5b..c380475 100644 --- a/app/LabelModelObject.h +++ b/app/LabelModelObject.h @@ -429,6 +429,10 @@ namespace glabels virtual QGraphicsItem* createGraphicsItem() = 0; virtual void updateGraphicsItem( QGraphicsItem* graphicsItem ) = 0; + protected: + void updateGraphicsItemMatrix( QGraphicsItem* graphicsItem ); + void updateGraphicsItemShadow( QGraphicsItem* graphicsItem ); + /////////////////////////////////////////////////////////////// // Private Members