QElectroTech
0.70
|
The PartPolygon class This class represents a polygon primitive which may be used to compose the drawing of an electrical element within the element editor. More...
#include <partpolygon.h>
Public Types | |
enum | { Type = UserType + 1105 } |
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 | closedChange () |
void | polygonChanged () |
Public Member Functions | |
PartPolygon (QETElementEditor *editor, QGraphicsItem *parent=nullptr) | |
PartPolygon::PartPolygon Constructor. More... | |
~PartPolygon () override | |
PartPolygon::~PartPolygon. More... | |
int | type () const override |
void | paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override |
PartPolygon::paint Draw this polygon. More... | |
QString | name () const override |
QString | xmlName () const override |
void | fromXml (const QDomElement &) override |
PartPolygon::fromXml Import the properties of this polygon from a xml element. More... | |
const QDomElement | toXml (QDomDocument &) const override |
PartPolygon::toXml Export this polygin in xml. More... | |
QPainterPath | shape () const override |
PartPolygon::shape. More... | |
QPainterPath | shadowShape () const override |
QRectF | boundingRect () const override |
PartPolygon::boundingRect. More... | |
bool | isUseless () const override |
PartPolygon::isUseless. More... | |
QRectF | sceneGeometricRect () const override |
PartPolygon::sceneGeometricRect. More... | |
void | startUserTransformation (const QRectF &) override |
PartPolygon::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 |
PartPolygon::handleUserTransformation Handle the user-induced transformation from initial_selection_rect to new_selection_rect. More... | |
QET::ScalingMethod | preferredScalingMethod () const override |
PartPolygon::preferredScalingMethod This method is called by the decorator when it needs to determine the best way to interactively scale a primitive. It is typically called when only a single primitive is being scaled. More... | |
QPolygonF | polygon () const |
void | setPolygon (const QPolygonF &polygon) |
PartPolygon::setPolygon Sets the item's polygon to be the given polygon. More... | |
void | addPoint (const QPointF &point) |
PartPolygon::addPoint Add new point to polygon. More... | |
void | setLastPoint (const QPointF &point) |
PartPolygon::setLastPoint Set the last point of polygon to . More... | |
void | removeLastPoint () |
PartPolygon::removeLastPoint Remove the last point of polygon. More... | |
bool | isClosed () const |
void | setClosed (bool close) |
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 () |
Protected Member Functions | |
QVariant | itemChange (GraphicsItemChange change, const QVariant &value) override |
PartPolygon::itemChange. More... | |
bool | sceneEventFilter (QGraphicsItem *watched, QEvent *event) override |
PartPolygon::sceneEventFilter. More... | |
void | contextMenuEvent (QGraphicsSceneContextMenuEvent *event) override |
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 | |
bool | closed |
QPolygonF | polygon |
PartPolygon::polygon. More... | |
Properties inherited from CustomElementGraphicPart | |
LineStyle | line_style |
LineWeight | line_weight |
Filling | filling |
Color | color |
bool | antialias |
Private Attributes | |
bool | m_closed |
QList< QPointF > | saved_points_ |
QPolygonF | m_polygon |
QPropertyUndoCommand * | m_undo_command |
int | m_vector_index = -1 |
QVector< QetGraphicsHandlerItem * > | m_handler_vector |
QAction * | m_insert_point |
QAction * | m_remove_point |
QPointF | m_context_menu_pos |
Additional Inherited Members | |
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 Attributes inherited from CustomElementGraphicPart | |
bool | m_hovered |
The PartPolygon class This class represents a polygon primitive which may be used to compose the drawing of an electrical element within the element editor.
Definition at line 33 of file partpolygon.h.
anonymous enum |
Enumerator | |
---|---|
Type |
Definition at line 54 of file partpolygon.h.
PartPolygon::PartPolygon | ( | QETElementEditor * | editor, |
QGraphicsItem * | parent = nullptr |
||
) |
PartPolygon::PartPolygon Constructor.
editor | : editor of this item |
parent | : parent item |
Definition at line 33 of file partpolygon.cpp.
References QET::Icons::Add, insertPoint(), m_insert_point, m_remove_point, QET::Icons::Remove, removePoint(), and QET::Icons::tr.
|
override |
Definition at line 49 of file partpolygon.cpp.
References m_undo_command, and removeHandler().
|
private |
|
private |
PartPolygon::addHandler Add handlers for this item.
Definition at line 452 of file partpolygon.cpp.
References QetGraphicsHandlerItem::handlerForPoint(), m_handler_vector, and m_polygon.
Referenced by adjusteHandlerPos(), itemChange(), and sceneSelectionChanged().
void PartPolygon::addPoint | ( | const QPointF & | point | ) |
PartPolygon::addPoint Add new point to polygon.
point |
Definition at line 219 of file partpolygon.cpp.
References m_polygon.
|
private |
PartPolygon::adjusteHandlerPos.
Definition at line 367 of file partpolygon.cpp.
References addHandler(), m_handler_vector, and m_polygon.
Referenced by handlerMouseMoveEvent(), itemChange(), and setPolygon().
|
override |
Definition at line 568 of file partpolygon.cpp.
References m_polygon, CustomElementGraphicPart::penWeight(), and SHADOWS_HEIGHT.
Referenced by sceneGeometricRect().
|
signal |
Referenced by setClosed(), and PolygonEditor::setPart().
|
overrideprotected |
Definition at line 340 of file partpolygon.cpp.
References QETElementEditor::contextMenu(), ElementScene::editor(), CustomElementPart::elementScene(), m_context_menu_pos, m_handler_vector, m_insert_point, m_remove_point, and ElementScene::Normal.
|
overridevirtual |
PartPolygon::fromXml Import the properties of this polygon from a xml element.
qde | : Xml document to use |
Implements CustomElementPart.
Definition at line 85 of file partpolygon.cpp.
References QET::attributeIsAReal(), m_closed, m_polygon, and CustomElementGraphicPart::stylesFromXml().
|
private |
PartPolygon::handlerMouseMoveEvent.
qghi | |
event |
Definition at line 405 of file partpolygon.cpp.
References adjusteHandlerPos(), CustomElementPart::elementScene(), m_polygon, m_vector_index, polygonChanged(), and ElementScene::snapToGrid().
Referenced by sceneEventFilter().
|
private |
PartPolygon::handlerMousePressEvent.
qghi | |
event |
Definition at line 391 of file partpolygon.cpp.
References m_polygon, m_undo_command, and QET::Icons::tr.
Referenced by sceneEventFilter().
|
private |
PartPolygon::handlerMouseReleaseEvent.
qghi | |
event |
Definition at line 425 of file partpolygon.cpp.
References CustomElementPart::elementScene(), m_polygon, m_undo_command, m_vector_index, QPropertyUndoCommand::setNewValue(), and ElementScene::undoStack().
Referenced by sceneEventFilter().
|
overridevirtual |
PartPolygon::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 175 of file partpolygon.cpp.
References m_polygon, CustomElementPart::mapPoints(), and saved_points_.
|
private |
PartPolygon::insertPoint Insert a point in this polygone.
Definition at line 485 of file partpolygon.cpp.
References CustomElementPart::elementScene(), m_closed, m_context_menu_pos, m_polygon, QetGraphicsHandlerUtility::polygonForInsertPoint(), QET::Icons::tr, and ElementScene::undoStack().
Referenced by PartPolygon().
|
inline |
Definition at line 84 of file partpolygon.h.
References m_closed.
Referenced by PolygonEditor::updatePolygonClosedState().
|
overridevirtual |
Implements CustomElementPart.
Definition at line 136 of file partpolygon.cpp.
References m_polygon.
|
overrideprotected |
change | |
value |
Definition at line 266 of file partpolygon.cpp.
References addHandler(), adjusteHandlerPos(), removeHandler(), and sceneSelectionChanged().
|
inlineoverridevirtual |
Implements CustomElementPart.
Definition at line 62 of file partpolygon.h.
References QET::Icons::tr.
|
override |
PartPolygon::paint Draw this polygon.
painter | |
options | |
widget |
Definition at line 62 of file partpolygon.cpp.
References CustomElementGraphicPart::applyStylesToQPainter(), CustomElementGraphicPart::drawShadowShape(), m_closed, CustomElementGraphicPart::m_hovered, and m_polygon.
QPolygonF PartPolygon::polygon | ( | ) | const |
Referenced by removePoint(), and setPolygon().
|
signal |
Referenced by handlerMouseMoveEvent(), PolygonEditor::setPart(), and setPolygon().
|
overridevirtual |
PartPolygon::preferredScalingMethod This method is called by the decorator when it needs to determine the best way to interactively scale a primitive. It is typically called when only a single primitive is being scaled.
Reimplemented from CustomElementPart.
Definition at line 188 of file partpolygon.cpp.
References QET::RoundScaleRatios.
|
private |
PartPolygon::removeHandler Remove the handlers of this item.
Definition at line 472 of file partpolygon.cpp.
References m_handler_vector.
Referenced by itemChange(), sceneSelectionChanged(), and ~PartPolygon().
void PartPolygon::removeLastPoint | ( | ) |
PartPolygon::removeLastPoint Remove the last point of polygon.
Definition at line 243 of file partpolygon.cpp.
References m_polygon.
Referenced by ESEventAddPolygon::mouseDoubleClickEvent().
|
private |
PartPolygon::removePoint remove a point on this polygon.
Definition at line 502 of file partpolygon.cpp.
References CustomElementPart::elementScene(), m_context_menu_pos, m_handler_vector, polygon(), QET::Icons::tr, and ElementScene::undoStack().
Referenced by PartPolygon().
|
overrideprotected |
PartPolygon::sceneEventFilter.
watched | |
event |
Definition at line 306 of file partpolygon.cpp.
References handlerMouseMoveEvent(), handlerMousePressEvent(), handlerMouseReleaseEvent(), m_handler_vector, m_vector_index, and QetGraphicsHandlerItem::Type.
|
overridevirtual |
PartPolygon::sceneGeometricRect.
Implements CustomElementPart.
Definition at line 153 of file partpolygon.cpp.
References boundingRect(), and m_polygon.
|
private |
PartPolygon::sceneSelectionChanged When the scene selection change, if there are several primitive selected, we remove the handler of this item.
Definition at line 440 of file partpolygon.cpp.
References addHandler(), and removeHandler().
Referenced by itemChange().
void PartPolygon::setClosed | ( | bool | close | ) |
Definition at line 252 of file partpolygon.cpp.
References closedChange(), and m_closed.
Referenced by ESEventAddPolygon::mouseDoubleClickEvent().
void PartPolygon::setLastPoint | ( | const QPointF & | point | ) |
PartPolygon::setLastPoint Set the last point of polygon to .
point |
Definition at line 230 of file partpolygon.cpp.
References m_polygon.
void PartPolygon::setPolygon | ( | const QPolygonF & | polygon | ) |
PartPolygon::setPolygon Sets the item's polygon to be the given polygon.
polygon |
Definition at line 205 of file partpolygon.cpp.
References adjusteHandlerPos(), m_polygon, polygon(), and polygonChanged().
|
overridevirtual |
Implements CustomElementGraphicPart.
Definition at line 550 of file partpolygon.cpp.
References m_closed, m_polygon, CustomElementGraphicPart::penWeight(), and shape().
|
override |
Definition at line 535 of file partpolygon.cpp.
References m_closed, CustomElementGraphicPart::m_hovered, m_polygon, CustomElementGraphicPart::penWeight(), and SHADOWS_HEIGHT.
Referenced by shadowShape().
|
overridevirtual |
PartPolygon::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 163 of file partpolygon.cpp.
References m_polygon, and saved_points_.
|
overridevirtual |
PartPolygon::toXml Export this polygin in xml.
xml_document | : Xml document to use for create the xml element |
Implements CustomElementPart.
Definition at line 116 of file partpolygon.cpp.
References m_closed, m_polygon, and CustomElementGraphicPart::stylesToXml().
|
inlineoverride |
Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartPolygon.
Definition at line 59 of file partpolygon.h.
References Type.
|
inlineoverridevirtual |
Implements CustomElementPart.
Definition at line 63 of file partpolygon.h.
|
private |
Definition at line 105 of file partpolygon.h.
Referenced by fromXml(), insertPoint(), isClosed(), paint(), setClosed(), shadowShape(), shape(), and toXml().
|
private |
Definition at line 113 of file partpolygon.h.
Referenced by contextMenuEvent(), insertPoint(), and removePoint().
|
private |
Definition at line 110 of file partpolygon.h.
Referenced by addHandler(), adjusteHandlerPos(), contextMenuEvent(), removeHandler(), removePoint(), and sceneEventFilter().
|
private |
Definition at line 111 of file partpolygon.h.
Referenced by contextMenuEvent(), and PartPolygon().
|
private |
Definition at line 107 of file partpolygon.h.
Referenced by addHandler(), addPoint(), adjusteHandlerPos(), boundingRect(), fromXml(), handlerMouseMoveEvent(), handlerMousePressEvent(), handlerMouseReleaseEvent(), handleUserTransformation(), insertPoint(), isUseless(), paint(), removeLastPoint(), sceneGeometricRect(), setLastPoint(), setPolygon(), shadowShape(), shape(), startUserTransformation(), and toXml().
|
private |
Definition at line 111 of file partpolygon.h.
Referenced by contextMenuEvent(), and PartPolygon().
|
private |
Definition at line 108 of file partpolygon.h.
Referenced by handlerMousePressEvent(), handlerMouseReleaseEvent(), and ~PartPolygon().
|
private |
Definition at line 109 of file partpolygon.h.
Referenced by handlerMouseMoveEvent(), handlerMouseReleaseEvent(), and sceneEventFilter().
|
private |
Definition at line 106 of file partpolygon.h.
Referenced by handleUserTransformation(), and startUserTransformation().
|
readwrite |
Definition at line 37 of file partpolygon.h.
|
readwrite |
Definition at line 38 of file partpolygon.h.
Referenced by ESEventAddPolygon::mouseDoubleClickEvent(), and PolygonEditor::updatePolygonPoints().