QElectroTech
0.70
|
#include <partline.h>
Public Types | |
enum | { Type = UserType + 1104 } |
Public Types inherited from CustomElementGraphicPart | |
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 } |
Signals | |
void | lineChanged () |
void | firstEndTypeChanged () |
void | secondEndTypeChanged () |
void | firstEndLengthChanged () |
void | secondEndLengthChanged () |
Public Member Functions | |
PartLine (QETElementEditor *, QGraphicsItem *=nullptr) | |
PartLine::PartLine Constructor. More... | |
~PartLine () override | |
Destructeur. More... | |
int | type () const override |
void | paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override |
PartLine::paint Draw this line. More... | |
QString | name () const override |
QString | xmlName () const override |
const QDomElement | toXml (QDomDocument &) const override |
PartLine::toXml Export this line in xml. More... | |
void | fromXml (const QDomElement &) override |
PartLine::fromXml Import the properties of this line from a xml element. More... | |
virtual QPointF | sceneP1 () const |
PartLine::sceneP1. More... | |
virtual QPointF | sceneP2 () const |
PartLine::sceneP2. More... | |
QPainterPath | shape () const override |
PartLine::shape. More... | |
QPainterPath | shadowShape () const override |
QRectF | boundingRect () const override |
PartLine::boundingRect. More... | |
bool | isUseless () const override |
PartLine::isUseless. More... | |
QRectF | sceneGeometricRect () const override |
PartLine::sceneGeometricRect. More... | |
void | startUserTransformation (const QRectF &) override |
PartLine::startUserTransformation Start the user-induced transformation, provided this primitive is contained within the initial_selection_rect bounding rectangle. More... | |
void | handleUserTransformation (const QRectF &, const QRectF &) override |
PartLine::handleUserTransformation Handle the user-induced transformation from initial_selection_rect to new_selection_rect. More... | |
QLineF | line () const |
void | setLine (const QLineF &line) |
Qet::EndType | firstEndType () const |
void | setFirstEndType (const Qet::EndType &et) |
Qet::EndType | secondEndType () const |
void | setSecondEndType (const Qet::EndType &et) |
qreal | firstEndLength () const |
void | setFirstEndLength (const qreal &l) |
qreal | secondEndLength () const |
void | setSecondEndLength (const qreal &l) |
Public Member Functions inherited from 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. 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 |
Public Member Functions inherited from CustomElementPart | |
CustomElementPart (QETElementEditor *editor) | |
virtual | ~CustomElementPart () |
Destructor. More... | |
virtual QETElementEditor * | elementEditor () const |
virtual void | updateCurrentPartEditor () const |
virtual ElementScene * | elementScene () const |
virtual QUndoStack & | undoStack () const |
virtual QGraphicsItem * | toItem () |
virtual QET::ScalingMethod | preferredScalingMethod () const |
Static Public Member Functions | |
static uint | requiredLengthForEndType (const Qet::EndType &) |
PartLine::requiredLengthForEndType. More... | |
static QList< QPointF > | fourEndPoints (const QPointF &, const QPointF &, const qreal &) |
PartLine::fourEndPoints Return the four interesting point needed to draw the shape at extremity of line (circle, diamond, arrow, triangle) This points are in order : O : point on the line, at a distance 'length' of the extremity A : point on the line at a 'length' of 2x the extremity length B : point at a distance of length O - O is the projection of B on the line C : point at a distance of length O - O is the projection of C on the line. More... | |
Static Public Member Functions inherited from CustomElementGraphicPart | |
static void | drawCross (const QPointF ¢er, QPainter *painter) |
CustomElementGraphicPart::drawCross Draw a cross at pos center. More... | |
Protected Member Functions | |
QVariant | itemChange (GraphicsItemChange change, const QVariant &value) override |
PartLine::itemChange. More... | |
bool | sceneEventFilter (QGraphicsItem *watched, QEvent *event) override |
PartLine::sceneEventFilter. More... | |
Protected Member Functions inherited from CustomElementGraphicPart | |
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 > &) |
Properties | |
Qet::EndType | end1 |
Qet::EndType | end2 |
qreal | length1 |
qreal | length2 |
QLineF | line |
Properties inherited from CustomElementGraphicPart | |
LineStyle | line_style |
LineWeight | line_weight |
Filling | filling |
Color | color |
bool | antialias |
Private Member Functions | |
PartLine (const PartLine &) | |
void | adjusteHandlerPos () |
PartLine::adjusteHandlerPos Adjust the position of the handler item. More... | |
void | handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event) |
PartLine::handlerMousePressEvent. More... | |
void | handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event) |
PartLine::handlerMouseMoveEvent. More... | |
void | handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event) |
PartLine::handlerMouseReleaseEvent. More... | |
void | sceneSelectionChanged () |
PartLine::sceneSelectionChanged When the scene selection change, if there are several primitive selected, we remove the handler of this item. More... | |
void | addHandler () |
PartLine::addHandler Add handlers for this item. More... | |
void | removeHandler () |
PartLine::removeHandler Remove the handlers of this item. More... | |
QPainterPath | path () const |
PartLine::path. More... | |
QList< QPointF > | fourShapePoints () const |
PartLine::fourShapePoints. More... | |
QRectF | firstEndCircleRect () const |
PartLine::firstEndCircleRect. More... | |
QRectF | secondEndCircleRect () const |
PartLine::secondEndCircleRect. More... | |
void | debugPaint (QPainter *) |
PartLine::debugPaint Display several composante of the drawing -the bounding rect -special points at each extremity -the quadrature of the circle at each extremity, even if itself is an other type. More... | |
Private Attributes | |
Qet::EndType | first_end |
qreal | first_length |
Qet::EndType | second_end |
qreal | second_length |
QList< QPointF > | saved_points_ |
QLineF | m_line |
int | m_vector_index = -1 |
QPropertyUndoCommand * | m_undo_command |
QVector< QetGraphicsHandlerItem * > | m_handler_vector |
Additional Inherited Members | |
Protected Attributes inherited from CustomElementGraphicPart | |
bool | m_hovered |
This class represents a line primitive which may be used to compose the drawing of an electrical element within the element editor. Lines may have specific visual ends (e.g. arrows) through the setFirstEndType and setSecondEndType methods. Their size can be defined using the setFirstEndLength and setSecondEndLength methods. Please note ends are not drawn if the required length for their drawing is longer than the line itself. In case there is room for a single end only, the first one get priority.
Definition at line 36 of file partline.h.
anonymous enum |
Enumerator | |
---|---|
Type |
Definition at line 63 of file partline.h.
PartLine::PartLine | ( | QETElementEditor * | editor, |
QGraphicsItem * | parent = nullptr |
||
) |
PartLine::PartLine Constructor.
editor | : QETElementEditor of this part |
parent | : parent item |
Definition at line 31 of file partline.cpp.
|
override |
Destructeur.
Definition at line 41 of file partline.cpp.
References m_undo_command, and removeHandler().
|
private |
|
private |
PartLine::addHandler Add handlers for this item.
Definition at line 313 of file partline.cpp.
References QetGraphicsHandlerItem::handlerForPoint(), m_handler_vector, and m_line.
Referenced by itemChange(), and sceneSelectionChanged().
|
private |
PartLine::adjusteHandlerPos Adjust the position of the handler item.
Definition at line 226 of file partline.cpp.
References m_handler_vector, and m_line.
Referenced by handlerMouseMoveEvent(), itemChange(), and setLine().
|
override |
Definition at line 522 of file partline.cpp.
References first_end, m_line, path(), CustomElementGraphicPart::penWeight(), second_end, and SHADOWS_HEIGHT.
Referenced by debugPaint().
|
private |
PartLine::debugPaint Display several composante of the drawing -the bounding rect -special points at each extremity -the quadrature of the circle at each extremity, even if itself is an other type.
painter |
Definition at line 497 of file partline.cpp.
References boundingRect(), first_length, firstEndCircleRect(), fourEndPoints(), m_line, second_length, and secondEndCircleRect().
|
private |
Definition at line 458 of file partline.cpp.
References first_length, fourEndPoints(), and m_line.
Referenced by debugPaint().
|
inline |
Definition at line 93 of file partline.h.
References first_length.
|
signal |
Referenced by setFirstEndLength(), and LineEditor::setPart().
|
inline |
Definition at line 89 of file partline.h.
References first_end.
|
signal |
Referenced by setFirstEndType(), and LineEditor::setPart().
|
static |
PartLine::fourEndPoints Return the four interesting point needed to draw the shape at extremity of line (circle, diamond, arrow, triangle) This points are in order : O : point on the line, at a distance 'length' of the extremity A : point on the line at a 'length' of 2x the extremity length B : point at a distance of length O - O is the projection of B on the line C : point at a distance of length O - O is the projection of C on the line.
end_point | : The concerned extremity |
other_point | : other needed point to define the line |
length | : length to use between the extremity and the point O |
Definition at line 601 of file partline.cpp.
Referenced by debugPaint(), firstEndCircleRect(), ElementPictureFactory::parseLine(), path(), and secondEndCircleRect().
|
private |
Definition at line 411 of file partline.cpp.
References m_line.
|
overridevirtual |
PartLine::fromXml Import the properties of this line from a xml element.
qde | : Xml document to use |
Implements CustomElementPart.
Definition at line 129 of file partline.cpp.
References Qet::endTypeFromString(), first_end, first_length, m_line, second_end, second_length, and CustomElementGraphicPart::stylesFromXml().
|
private |
PartLine::handlerMouseMoveEvent.
qghi | |
event |
Definition at line 263 of file partline.cpp.
References adjusteHandlerPos(), CustomElementPart::elementScene(), m_line, m_vector_index, and ElementScene::snapToGrid().
Referenced by sceneEventFilter().
|
private |
PartLine::handlerMousePressEvent.
qghi | |
event |
Definition at line 247 of file partline.cpp.
References QPropertyUndoCommand::enableAnimation(), m_line, m_undo_command, and QET::Icons::tr.
Referenced by sceneEventFilter().
|
private |
PartLine::handlerMouseReleaseEvent.
qghi | |
event |
Definition at line 286 of file partline.cpp.
References CustomElementPart::elementScene(), m_line, m_undo_command, m_vector_index, QPropertyUndoCommand::setNewValue(), and ElementScene::undoStack().
Referenced by sceneEventFilter().
|
overridevirtual |
PartLine::handleUserTransformation Handle the user-induced transformation from initial_selection_rect to new_selection_rect.
initial_selection_rect | |
new_selection_rect |
Implements CustomElementPart.
Definition at line 580 of file partline.cpp.
References m_line, CustomElementPart::mapPoints(), and saved_points_.
|
overridevirtual |
Implements CustomElementPart.
Definition at line 546 of file partline.cpp.
References m_line.
Referenced by paint().
|
overrideprotected |
change | |
value |
Definition at line 148 of file partline.cpp.
References addHandler(), adjusteHandlerPos(), removeHandler(), and sceneSelectionChanged().
QLineF PartLine::line | ( | ) | const |
Referenced by setLine().
|
signal |
Referenced by setLine(), and LineEditor::setPart().
|
inlineoverridevirtual |
Implements CustomElementPart.
Definition at line 71 of file partline.h.
References QET::Icons::tr.
|
override |
PartLine::paint Draw this line.
painter | |
options | |
widget |
Definition at line 73 of file partline.cpp.
References CustomElementGraphicPart::applyStylesToQPainter(), CustomElementGraphicPart::drawShadowShape(), first_end, isUseless(), CustomElementGraphicPart::m_hovered, m_line, path(), and second_end.
|
private |
Definition at line 674 of file partline.cpp.
References Qet::Circle, Qet::Diamond, first_end, first_length, fourEndPoints(), length1, length2, m_line, CustomElementGraphicPart::penWeight(), requiredLengthForEndType(), second_end, second_length, Qet::Simple, and Qet::Triangle.
Referenced by boundingRect(), paint(), shadowShape(), and shape().
|
private |
PartLine::removeHandler Remove the handlers of this item.
Definition at line 336 of file partline.cpp.
References m_handler_vector.
Referenced by itemChange(), sceneSelectionChanged(), and ~PartLine().
|
static |
PartLine::requiredLengthForEndType.
end_type |
Definition at line 54 of file partline.cpp.
References Qet::Circle, Qet::Diamond, Qet::Simple, and Qet::Triangle.
Referenced by ElementPictureFactory::parseLine(), and path().
|
overrideprotected |
watched | |
event |
Definition at line 188 of file partline.cpp.
References handlerMouseMoveEvent(), handlerMousePressEvent(), handlerMouseReleaseEvent(), m_handler_vector, m_vector_index, and QetGraphicsHandlerItem::Type.
|
overridevirtual |
Implements CustomElementPart.
Definition at line 557 of file partline.cpp.
|
virtual |
Definition at line 349 of file partline.cpp.
References m_line.
Referenced by sceneGeometricRect(), startUserTransformation(), and toXml().
|
virtual |
Definition at line 357 of file partline.cpp.
References m_line.
Referenced by sceneGeometricRect(), startUserTransformation(), and toXml().
|
private |
PartLine::sceneSelectionChanged When the scene selection change, if there are several primitive selected, we remove the handler of this item.
Definition at line 301 of file partline.cpp.
References addHandler(), and removeHandler().
Referenced by itemChange().
|
private |
PartLine::secondEndCircleRect.
Definition at line 476 of file partline.cpp.
References fourEndPoints(), m_line, and second_length.
Referenced by debugPaint().
|
inline |
Definition at line 95 of file partline.h.
References second_length.
|
signal |
Referenced by LineEditor::setPart(), and setSecondEndLength().
|
inline |
Definition at line 91 of file partline.h.
References second_end.
|
signal |
Referenced by LineEditor::setPart(), and setSecondEndType().
void PartLine::setFirstEndLength | ( | const qreal & | l | ) |
Definition at line 649 of file partline.cpp.
References first_length, firstEndLengthChanged(), and m_line.
void PartLine::setFirstEndType | ( | const Qet::EndType & | et | ) |
Definition at line 633 of file partline.cpp.
References first_end, and firstEndTypeChanged().
void PartLine::setLine | ( | const QLineF & | line | ) |
Definition at line 624 of file partline.cpp.
References adjusteHandlerPos(), line(), lineChanged(), and m_line.
Referenced by ESEventAddLine::mousePressEvent().
void PartLine::setSecondEndLength | ( | const qreal & | l | ) |
Definition at line 658 of file partline.cpp.
References m_line, second_length, and secondEndLengthChanged().
void PartLine::setSecondEndType | ( | const Qet::EndType & | et | ) |
Definition at line 641 of file partline.cpp.
References second_end, and secondEndTypeChanged().
|
overridevirtual |
Implements CustomElementGraphicPart.
Definition at line 386 of file partline.cpp.
References first_end, m_line, path(), CustomElementGraphicPart::penWeight(), second_end, and shape().
|
override |
Definition at line 365 of file partline.cpp.
References first_end, CustomElementGraphicPart::m_hovered, m_line, path(), CustomElementGraphicPart::penWeight(), second_end, and SHADOWS_HEIGHT.
Referenced by shadowShape().
|
overridevirtual |
PartLine::startUserTransformation Start the user-induced transformation, provided this primitive is contained within the initial_selection_rect bounding rectangle.
initial_selection_rect |
Implements CustomElementPart.
Definition at line 567 of file partline.cpp.
References saved_points_, sceneP1(), and sceneP2().
|
overridevirtual |
PartLine::toXml Export this line in xml.
xml_document | : Xml document to use for create the xml element. |
Implements CustomElementPart.
Definition at line 105 of file partline.cpp.
References Qet::endTypeToString(), first_end, first_length, sceneP1(), sceneP2(), second_end, second_length, and CustomElementGraphicPart::stylesToXml().
|
inlineoverride |
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartLine.
Definition at line 69 of file partline.h.
References Type.
|
inlineoverridevirtual |
Implements CustomElementPart.
Definition at line 72 of file partline.h.
|
private |
Definition at line 119 of file partline.h.
Referenced by boundingRect(), firstEndType(), fromXml(), paint(), path(), setFirstEndType(), shadowShape(), shape(), and toXml().
|
private |
Definition at line 120 of file partline.h.
Referenced by debugPaint(), firstEndCircleRect(), firstEndLength(), fromXml(), path(), setFirstEndLength(), and toXml().
|
private |
Definition at line 128 of file partline.h.
Referenced by addHandler(), adjusteHandlerPos(), removeHandler(), and sceneEventFilter().
|
private |
Definition at line 125 of file partline.h.
Referenced by addHandler(), adjusteHandlerPos(), boundingRect(), debugPaint(), firstEndCircleRect(), fourShapePoints(), fromXml(), handlerMouseMoveEvent(), handlerMousePressEvent(), handlerMouseReleaseEvent(), handleUserTransformation(), isUseless(), paint(), path(), sceneP1(), sceneP2(), secondEndCircleRect(), setFirstEndLength(), setLine(), setSecondEndLength(), shadowShape(), and shape().
|
private |
Definition at line 127 of file partline.h.
Referenced by handlerMousePressEvent(), handlerMouseReleaseEvent(), and ~PartLine().
|
private |
Definition at line 126 of file partline.h.
Referenced by handlerMouseMoveEvent(), handlerMouseReleaseEvent(), and sceneEventFilter().
|
private |
Definition at line 124 of file partline.h.
Referenced by handleUserTransformation(), and startUserTransformation().
|
private |
Definition at line 122 of file partline.h.
Referenced by boundingRect(), fromXml(), paint(), path(), secondEndType(), setSecondEndType(), shadowShape(), shape(), and toXml().
|
private |
Definition at line 123 of file partline.h.
Referenced by debugPaint(), fromXml(), path(), secondEndCircleRect(), secondEndLength(), setSecondEndLength(), and toXml().
|
readwrite |
Definition at line 40 of file partline.h.
|
readwrite |
Definition at line 41 of file partline.h.
|
readwrite |
Definition at line 42 of file partline.h.
Referenced by path().
|
readwrite |
Definition at line 43 of file partline.h.
Referenced by path().
|
readwrite |
Definition at line 44 of file partline.h.
Referenced by ESEventAddLine::mouseMoveEvent().