QElectroTech
0.70
|
The CustomElementGraphicPart class This class is the base for all home-made primitive like line, rectangle, ellipse etc.... It provides methods and enums to manage style attributes available for primitive (color, pen style, etc...) More...
#include <customelementgraphicpart.h>
Public Types | |
enum | LineStyle { NormalStyle, DashedStyle, DottedStyle, DashdottedStyle } |
enum | LineWeight { NoneWeight, ThinWeight, NormalWeight, UltraWeight, BigWeight } |
enum | Filling { NoneFilling, BlackFilling, WhiteFilling, GreenFilling, RedFilling, BlueFilling, GrayFilling, BrunFilling, YellowFilling, CyanFilling, MagentaFilling, LightgrayFilling, OrangeFilling, PurpleFilling, HorFilling, VerFilling, BdiagFilling, FdiagFilling } |
enum | Color { BlackColor, WhiteColor, GreenColor, RedColor, BlueColor, GrayColor, BrunColor, YellowColor, CyanColor, MagentaColor, LightgrayColor, OrangeColor, PurpleColor, NoneColor } |
Public Member Functions | |
CustomElementGraphicPart (QETElementEditor *editor, QGraphicsItem *parent=nullptr) | |
CustomElementGraphicPart::CustomElementGraphicPart Default constructor. By default, item is selectable, send geometry change (Qt > 4.6), accept mouse left button and accept hover event. More... | |
~CustomElementGraphicPart () override | |
CustomElementGraphicPart::~CustomElementGraphicPart Destructor. More... | |
LineStyle | lineStyle () const |
void | setLineStyle (const LineStyle ls) |
CustomElementGraphicPart::setLineStyle Set line style to ls. More... | |
LineWeight | lineWeight () const |
void | setLineWeight (const LineWeight lw) |
CustomElementGraphicPart::setLineWeight Set line weight to lw. More... | |
qreal | penWeight () const |
CustomElementGraphicPart::penWeight. More... | |
Filling | filling () const |
void | setFilling (const Filling f) |
CustomElementGraphicPart::setFilling Set filling to f. More... | |
Color | color () const |
void | setColor (const Color c) |
CustomElementGraphicPart::setColor Set color to c. More... | |
bool | antialiased () const |
void | setAntialiased (const bool b) |
CustomElementGraphicPart::setAntialiased Set antialias to b. More... | |
void | setProperty (const char *name, const QVariant &value) override |
QVariant | property (const char *name) const override |
virtual QPainterPath | shadowShape () const =0 |
Public Member Functions inherited from CustomElementPart | |
CustomElementPart (QETElementEditor *editor) | |
virtual | ~CustomElementPart () |
Destructor. More... | |
virtual void | fromXml (const QDomElement &)=0 |
virtual const QDomElement | toXml (QDomDocument &) const =0 |
virtual bool | isUseless () const =0 |
virtual QRectF | sceneGeometricRect () const =0 |
virtual void | startUserTransformation (const QRectF &)=0 |
virtual void | handleUserTransformation (const QRectF &, const QRectF &)=0 |
virtual QETElementEditor * | elementEditor () const |
virtual void | updateCurrentPartEditor () const |
virtual ElementScene * | elementScene () const |
virtual QUndoStack & | undoStack () const |
virtual QString | name () const =0 |
virtual QString | xmlName () const =0 |
virtual QGraphicsItem * | toItem () |
virtual QET::ScalingMethod | preferredScalingMethod () const |
Static Public Member Functions | |
static void | drawCross (const QPointF ¢er, QPainter *painter) |
CustomElementGraphicPart::drawCross Draw a cross at pos center. More... | |
Protected Member Functions | |
void | stylesToXml (QDomElement &) const |
CustomElementGraphicPart::stylesToXml Write the curent style to xml element. The style are stored like this: name-of-style:value;name-of-style:value Each style separate by ; and name-style/value are separate by : More... | |
void | stylesFromXml (const QDomElement &) |
CustomElementGraphicPart::stylesFromXml Read the style used by this, from a xml element. More... | |
void | resetStyles () |
CustomElementGraphicPart::resetStyles Reset the curent style to default, same style of default constructor. More... | |
void | applyStylesToQPainter (QPainter &) const |
CustomElementGraphicPart::applyStylesToQPainter Apply the current style to the QPainter. More... | |
void | drawShadowShape (QPainter *painter) |
CustomElementGraphicPart::drawShadowShape Draw a transparent blue shadow arround the shape of this item. The QPainterPathStroker used to draw shadows have a width of SHADOWS_HEIGHT Be carefull if penWeight of this item is to 0 the outline of strock is bigger of 0.5. More... | |
QVariant | itemChange (GraphicsItemChange change, const QVariant &value) override |
CustomElementGraphicPart::itemChange Reimplemented from QGraphicsObject. If the item position change call updateCurrentPartEditor() the change is always send to QGraphicsObject. More... | |
void | hoverEnterEvent (QGraphicsSceneHoverEvent *event) override |
CustomElementGraphicPart::hoverEnterEvent Reimplemented from QGraphicsObject. Set m_hovered to true. More... | |
void | hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override |
CustomElementGraphicPart::hoverLeaveEvent Reimplemented from QGraphicsObject. Set m_hovered to false. More... | |
void | mousePressEvent (QGraphicsSceneMouseEvent *event) override |
void | mouseMoveEvent (QGraphicsSceneMouseEvent *event) override |
void | mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override |
Protected Member Functions inherited from CustomElementPart | |
QList< QPointF > | mapPoints (const QRectF &, const QRectF &, const QList< QPointF > &) |
Protected Attributes | |
bool | m_hovered |
Properties | |
LineStyle | line_style |
LineWeight | line_weight |
Filling | filling |
Color | color |
bool | antialias |
Private Attributes | |
LineStyle | _linestyle |
LineWeight | _lineweight |
Filling | _filling |
Color | _color |
bool | _antialiased |
QPointF | m_origin_pos |
The CustomElementGraphicPart class This class is the base for all home-made primitive like line, rectangle, ellipse etc.... It provides methods and enums to manage style attributes available for primitive (color, pen style, etc...)
Definition at line 33 of file customelementgraphicpart.h.
Enumerator | |
---|---|
BlackColor | |
WhiteColor | |
GreenColor | |
RedColor | |
BlueColor | |
GrayColor | |
BrunColor | |
YellowColor | |
CyanColor | |
MagentaColor | |
LightgrayColor | |
OrangeColor | |
PurpleColor | |
NoneColor |
Definition at line 59 of file customelementgraphicpart.h.
Definition at line 55 of file customelementgraphicpart.h.
Enumerator | |
---|---|
NormalStyle | |
DashedStyle | |
DottedStyle | |
DashdottedStyle |
Definition at line 47 of file customelementgraphicpart.h.
Enumerator | |
---|---|
NoneWeight | |
ThinWeight | |
NormalWeight | |
UltraWeight | |
BigWeight |
Definition at line 51 of file customelementgraphicpart.h.
CustomElementGraphicPart::CustomElementGraphicPart | ( | QETElementEditor * | editor, |
QGraphicsItem * | parent = nullptr |
||
) |
CustomElementGraphicPart::CustomElementGraphicPart Default constructor. By default, item is selectable, send geometry change (Qt > 4.6), accept mouse left button and accept hover event.
editor | QETElement editor that belong this. |
Definition at line 29 of file customelementgraphicpart.cpp.
|
override |
CustomElementGraphicPart::~CustomElementGraphicPart Destructor.
Definition at line 47 of file customelementgraphicpart.cpp.
|
inline |
Definition at line 84 of file customelementgraphicpart.h.
References _antialiased.
|
protected |
CustomElementGraphicPart::applyStylesToQPainter Apply the current style to the QPainter.
painter |
Definition at line 305 of file customelementgraphicpart.cpp.
References _antialiased, _color, _filling, _linestyle, _lineweight, BdiagFilling, BigWeight, BlackColor, BlackFilling, BlueColor, BlueFilling, BrunColor, BrunFilling, CyanColor, CyanFilling, DashdottedStyle, DashedStyle, DottedStyle, FdiagFilling, GrayColor, GrayFilling, GreenColor, GreenFilling, HorFilling, LightgrayColor, LightgrayFilling, MagentaColor, MagentaFilling, NoneColor, NoneFilling, NoneWeight, NormalStyle, NormalWeight, OrangeColor, OrangeFilling, PurpleColor, PurpleFilling, RedColor, RedFilling, ThinWeight, UltraWeight, VerFilling, WhiteColor, WhiteFilling, YellowColor, and YellowFilling.
Referenced by PartArc::paint(), PartEllipse::paint(), PartRectangle::paint(), PartPolygon::paint(), and PartLine::paint().
|
inline |
Definition at line 81 of file customelementgraphicpart.h.
References _color.
Referenced by PartEllipse::addHandler(), PartArc::addHandler(), PartRectangle::addHandler(), drawCross(), and drawShadowShape().
|
static |
CustomElementGraphicPart::drawCross Draw a cross at pos center.
center | : center of cross |
painter | : painter to use for draw cross, the painter state is restored at end of this method. |
Definition at line 56 of file customelementgraphicpart.cpp.
References color().
Referenced by PartArc::paint(), PartEllipse::paint(), and PartRectangle::paint().
|
protected |
CustomElementGraphicPart::drawShadowShape Draw a transparent blue shadow arround the shape of this item. The QPainterPathStroker used to draw shadows have a width of SHADOWS_HEIGHT Be carefull if penWeight of this item is to 0 the outline of strock is bigger of 0.5.
painter | : painter to use for draw this shadows |
Definition at line 380 of file customelementgraphicpart.cpp.
References color(), SHADOWS_HEIGHT, and shadowShape().
Referenced by PartArc::paint(), PartEllipse::paint(), PartRectangle::paint(), PartPolygon::paint(), PartTerminal::paint(), and PartLine::paint().
|
inline |
Definition at line 78 of file customelementgraphicpart.h.
References _filling.
|
overrideprotected |
CustomElementGraphicPart::hoverEnterEvent Reimplemented from QGraphicsObject. Set m_hovered to true.
event |
Definition at line 421 of file customelementgraphicpart.cpp.
References m_hovered.
|
overrideprotected |
CustomElementGraphicPart::hoverLeaveEvent Reimplemented from QGraphicsObject. Set m_hovered to false.
event |
Definition at line 433 of file customelementgraphicpart.cpp.
References m_hovered.
|
overrideprotected |
CustomElementGraphicPart::itemChange Reimplemented from QGraphicsObject. If the item position change call updateCurrentPartEditor() the change is always send to QGraphicsObject.
change | |
value |
Definition at line 406 of file customelementgraphicpart.cpp.
References CustomElementPart::updateCurrentPartEditor().
|
inline |
Definition at line 71 of file customelementgraphicpart.h.
References _linestyle.
|
inline |
Definition at line 74 of file customelementgraphicpart.h.
References _lineweight.
|
overrideprotected |
Definition at line 447 of file customelementgraphicpart.cpp.
References CustomElementPart::elementScene(), and m_origin_pos.
|
overrideprotected |
Definition at line 439 of file customelementgraphicpart.cpp.
References m_origin_pos.
|
overrideprotected |
Definition at line 458 of file customelementgraphicpart.cpp.
References CustomElementPart::elementScene(), QPropertyUndoCommand::enableAnimation(), m_origin_pos, QET::Icons::tr, and ElementScene::undoStack().
Referenced by PartEllipse::mouseReleaseEvent(), PartArc::mouseReleaseEvent(), and PartRectangle::mouseReleaseEvent().
qreal CustomElementGraphicPart::penWeight | ( | ) | const |
CustomElementGraphicPart::penWeight.
Definition at line 94 of file customelementgraphicpart.cpp.
References _lineweight, BigWeight, NoneWeight, NormalWeight, ThinWeight, and UltraWeight.
Referenced by AbstractPartEllipse::boundingRect(), PartPolygon::boundingRect(), PartRectangle::boundingRect(), PartLine::boundingRect(), PartLine::path(), PartEllipse::shadowShape(), PartArc::shadowShape(), PartPolygon::shadowShape(), PartRectangle::shadowShape(), PartLine::shadowShape(), PartEllipse::shape(), PartArc::shape(), PartPolygon::shape(), PartRectangle::shape(), and PartLine::shape().
|
inlineoverridevirtual |
Get the current value of a specific primitive property
Implements CustomElementPart.
Definition at line 91 of file customelementgraphicpart.h.
References CustomElementPart::name().
Referenced by EllipseEditor::editingFinished(), LineEditor::lineEditingFinished(), StyleEditor::makeUndo(), ArcEditor::updateArcA(), ArcEditor::updateArcRect(), ArcEditor::updateArcS(), RectangleEditor::updateForm(), TerminalEditor::updateForm(), EllipseEditor::updateForm(), ArcEditor::updateForm(), LineEditor::updateLineEndLength1(), LineEditor::updateLineEndLength2(), LineEditor::updateLineEndType1(), LineEditor::updateLineEndType2(), PolygonEditor::updatePolygonClosedState(), PolygonEditor::updatePolygonPoints(), TerminalEditor::updatePos(), and TerminalEditor::updateTerminalO().
|
protected |
CustomElementGraphicPart::resetStyles Reset the curent style to default, same style of default constructor.
Definition at line 291 of file customelementgraphicpart.cpp.
References _antialiased, _color, _filling, _linestyle, _lineweight, BlackColor, NoneFilling, NormalStyle, and NormalWeight.
Referenced by stylesFromXml().
void CustomElementGraphicPart::setAntialiased | ( | const bool | b | ) |
CustomElementGraphicPart::setAntialiased Set antialias to b.
b |
Definition at line 132 of file customelementgraphicpart.cpp.
References _antialiased.
void CustomElementGraphicPart::setColor | ( | const Color | c | ) |
CustomElementGraphicPart::setColor Set color to c.
c |
Definition at line 120 of file customelementgraphicpart.cpp.
References _color.
void CustomElementGraphicPart::setFilling | ( | const Filling | f | ) |
CustomElementGraphicPart::setFilling Set filling to f.
f |
Definition at line 108 of file customelementgraphicpart.cpp.
References _filling.
void CustomElementGraphicPart::setLineStyle | ( | const LineStyle | ls | ) |
CustomElementGraphicPart::setLineStyle Set line style to ls.
ls |
Definition at line 71 of file customelementgraphicpart.cpp.
References _linestyle.
void CustomElementGraphicPart::setLineWeight | ( | const LineWeight | lw | ) |
CustomElementGraphicPart::setLineWeight Set line weight to lw.
lw |
Definition at line 83 of file customelementgraphicpart.cpp.
References _lineweight.
|
inlineoverridevirtual |
Set a specific property of the primitive
Implements CustomElementPart.
Definition at line 90 of file customelementgraphicpart.h.
References CustomElementPart::name().
|
pure virtual |
Implemented in PartLine, PartRectangle, PartPolygon, PartTerminal, PartArc, and PartEllipse.
Referenced by drawShadowShape().
|
protected |
CustomElementGraphicPart::stylesFromXml Read the style used by this, from a xml element.
qde | : QDomElement used to read the style |
Definition at line 213 of file customelementgraphicpart.cpp.
References _antialiased, _color, _filling, _linestyle, _lineweight, BdiagFilling, BigWeight, BlackColor, BlackFilling, BlueColor, BlueFilling, BrunColor, BrunFilling, CyanColor, CyanFilling, DashdottedStyle, DashedStyle, DottedStyle, FdiagFilling, GrayColor, GrayFilling, GreenColor, GreenFilling, HorFilling, LightgrayColor, LightgrayFilling, MagentaColor, MagentaFilling, NoneColor, NoneFilling, NoneWeight, NormalStyle, NormalWeight, OrangeColor, OrangeFilling, PurpleColor, PurpleFilling, RedColor, RedFilling, resetStyles(), ThinWeight, UltraWeight, VerFilling, WhiteColor, WhiteFilling, YellowColor, and YellowFilling.
Referenced by PartArc::fromXml(), PartEllipse::fromXml(), PartPolygon::fromXml(), PartRectangle::fromXml(), and PartLine::fromXml().
|
protected |
CustomElementGraphicPart::stylesToXml Write the curent style to xml element. The style are stored like this: name-of-style:value;name-of-style:value Each style separate by ; and name-style/value are separate by :
qde | : QDOmElement used to write the style. |
Definition at line 147 of file customelementgraphicpart.cpp.
References _antialiased, _color, _filling, _linestyle, _lineweight, BdiagFilling, BigWeight, BlackColor, BlackFilling, BlueColor, BlueFilling, BrunColor, BrunFilling, CyanColor, CyanFilling, DashdottedStyle, DashedStyle, DottedStyle, FdiagFilling, GrayColor, GrayFilling, GreenColor, GreenFilling, HorFilling, LightgrayColor, LightgrayFilling, MagentaColor, MagentaFilling, NoneColor, NoneFilling, NoneWeight, NormalStyle, NormalWeight, OrangeColor, OrangeFilling, PurpleColor, PurpleFilling, RedColor, RedFilling, ThinWeight, UltraWeight, VerFilling, WhiteColor, WhiteFilling, YellowColor, and YellowFilling.
Referenced by PartArc::toXml(), PartEllipse::toXml(), PartRectangle::toXml(), PartPolygon::toXml(), and PartLine::toXml().
|
private |
Definition at line 117 of file customelementgraphicpart.h.
Referenced by antialiased(), applyStylesToQPainter(), resetStyles(), setAntialiased(), stylesFromXml(), and stylesToXml().
|
private |
Definition at line 116 of file customelementgraphicpart.h.
Referenced by applyStylesToQPainter(), color(), resetStyles(), setColor(), stylesFromXml(), and stylesToXml().
|
private |
Definition at line 115 of file customelementgraphicpart.h.
Referenced by applyStylesToQPainter(), filling(), resetStyles(), setFilling(), stylesFromXml(), and stylesToXml().
|
private |
Definition at line 113 of file customelementgraphicpart.h.
Referenced by applyStylesToQPainter(), lineStyle(), resetStyles(), setLineStyle(), stylesFromXml(), and stylesToXml().
|
private |
Definition at line 114 of file customelementgraphicpart.h.
Referenced by applyStylesToQPainter(), lineWeight(), penWeight(), resetStyles(), setLineWeight(), stylesFromXml(), and stylesToXml().
|
protected |
Definition at line 111 of file customelementgraphicpart.h.
Referenced by hoverEnterEvent(), hoverLeaveEvent(), PartArc::paint(), PartEllipse::paint(), PartRectangle::paint(), PartPolygon::paint(), PartTerminal::paint(), PartLine::paint(), PartArc::shape(), PartEllipse::shape(), PartPolygon::shape(), PartRectangle::shape(), and PartLine::shape().
|
private |
Definition at line 118 of file customelementgraphicpart.h.
Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().
|
readwrite |
Definition at line 43 of file customelementgraphicpart.h.
|
readwrite |
Definition at line 42 of file customelementgraphicpart.h.
|
readwrite |
Definition at line 41 of file customelementgraphicpart.h.
|
readwrite |
Definition at line 39 of file customelementgraphicpart.h.
|
readwrite |
Definition at line 40 of file customelementgraphicpart.h.