QElectroTech 0.100.0-dev
|
The ElementScene class This class is the canvas allowing the visual edition of an electrical element. It displays the various primitives composing the drawing of the element, the border due to its fixed size and its hotspot. More...
#include <elementscene.h>
Inherits QGraphicsScene.
Public Types | |
enum | Behavior { Normal , PasteArea , AddPart } |
enum | ItemOption { SortByZValue = 1 , IncludeTerminals = 2 , IncludeHelperItems = 4 , Selected = 8 , NonSelected = 16 , SelectedOrNot = 24 } |
Public Slots | |
void | slot_select (const ElementContent &) |
ElementScene::slot_select Select the item in content, every others items in the scene are deselected. | |
void | slot_selectAll () |
ElementScene::slot_selectAll Select all items. | |
void | slot_deselectAll () |
ElementScene::slot_deselectAll deselect all item. | |
void | slot_invertSelection () |
ElementScene::slot_invertSelection Inverse Selection. | |
void | slot_delete () |
ElementScene::slot_delete Delete selected items. | |
void | slot_editNames () |
ElementScene::slot_editNames Launch a dialog for edit the names of the edited element. | |
void | slot_editAuthorInformations () |
ElementScene::slot_editAuthorInformations Starts a dialog to edit the additional information of this element. Concretely, this free field is intended to receive information on the author of the element, its license, etc. | |
void | slot_editProperties () |
ElementScene::slot_editProperties Open dialog to edit the element properties. | |
void | managePrimitivesGroups () |
ElementScene::managePrimitivesGroups Ensure the decorator is adequately shown, hidden or updated so it always represents the current selection. | |
void | stackAction (ElementEditionCommand *) |
ElementScene::stackAction Push the provided command on the undo stack. | |
Signals | |
void | partsAdded () |
Signal emitted after one or several parts were added. | |
void | partsRemoved () |
Signal emitted after one or several parts were removed. | |
void | partsZValueChanged () |
Signal emitted when the zValue of one or several parts change. | |
void | pasteAreaDefined (const QRectF &) |
Signal emitted when users have defined the copy/paste area. | |
void | needZoomFit () |
Signal emitted when need zoomFit. | |
void | elementInfoChanged () |
Public Member Functions | |
ElementScene (QETElementEditor *, QObject *=nullptr) | |
ElementScene::ElementScene constructor. | |
~ElementScene () override | |
ElementScene::~ElementScene. | |
ElementData | elementData () |
ElementScene::elementData. | |
void | setElementData (ElementData data) |
void | setEventInterface (ESEventInterface *event_interface) |
ElementScene::setEventInterface Set a new event interface. | |
void | clearEventInterface () |
ElementScene::clearEventInterface Clear the current event interface. | |
void | setBehavior (ElementScene::Behavior) |
ElementScene::setBehavior Modify the current behavior of this scene. | |
ElementScene::Behavior | behavior () const |
QPointF | snapToGrid (QPointF point) |
ElementScene::snapToGrid Rounds the coordinates of the point passed as a parameter so that this point is aligned with the grid. | |
virtual int | xGrid () const |
ElementScene::xGrid. | |
virtual int | yGrid () const |
ElementScene::yGrid. | |
virtual void | setGrid (int, int) |
ElementScene::setGrid. | |
virtual const QDomDocument | toXml (bool=true) |
ElementScene::toXml Export this element as a xml file. | |
virtual QRectF | boundingRectFromXml (const QDomDocument &) |
ElementScene::boundingRectFromXml. | |
virtual void | fromXml (const QDomDocument &, const QPointF &=QPointF(), bool=true, ElementContent *=nullptr) |
ElementScene::fromXml Imports the element described in an XML document. If a position is specified, the imported elements are positioned in such a way that the upper left corner of the smallest rectangle that can surround them all (the bounding rect) either at this position. | |
virtual void | reset () |
ElementScene::reset Remove all QGraphicsItems in the scene and clear the undo stack. | |
virtual QList< CustomElementPart * > | primitives () const |
ElementScene::primitives. | |
virtual QList< QGraphicsItem * > | zItems (ItemOptions options=ItemOptions(SortByZValue|IncludeTerminals|SelectedOrNot)) const |
ElementScene::zItems. | |
virtual ElementContent | selectedContent () const |
ElementScene::selectedContent. | |
virtual void | getPasteArea (const QRectF &) |
ElementScene::getPasteArea. | |
QRectF | elementSceneGeometricRect () const |
ElementScene::elementSceneGeometricRect. | |
bool | containsTerminals () const |
ElementScene::containsTerminals. | |
QUndoStack & | undoStack () |
ElementScene::undoStack. | |
QGIManager & | qgiManager () |
ElementScene::qgiManager. | |
bool | wasCopiedFromThisElement (const QString &) |
ElementScene::wasCopiedFromThisElement. | |
void | cut () |
ElementScene::cut Handles the fact of cutting the selection = exporting it in XML to the clipboard then deleting it. | |
void | copy () |
ElementScene::copy Handles the fact of copying the selection = exporting it as XML to the clipboard. | |
QETElementEditor * | editor () const |
ElementScene::editor. | |
void | addItems (QVector< QGraphicsItem * > items) |
ElementScene::addItems Add items to the scene and emit partsAdded. Prefer always use this method instead of QGraphicsScene::addItem even if you want to add one item, for gain the signal emission. | |
void | removeItems (QVector< QGraphicsItem * > items) |
ElementScene::removeItems Remove items from the scene and emit partsRemoved. Prefer always use this method instead of QGraphicsScene::removeItem even if you want to remove one item, for gain the signal emission. | |
Static Public Member Functions | |
static bool | clipboardMayContainElement () |
ElementScene::clipboardMayContainElement. | |
Protected Member Functions | |
void | mouseMoveEvent (QGraphicsSceneMouseEvent *) override |
ElementScene::mouseMoveEvent. | |
void | mousePressEvent (QGraphicsSceneMouseEvent *) override |
ElementScene::mousePressEvent. | |
void | mouseReleaseEvent (QGraphicsSceneMouseEvent *) override |
ElementScene::mouseReleaseEvent. | |
void | mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override |
ElementScene::mouseDoubleClickEvent. | |
void | keyPressEvent (QKeyEvent *event) override |
ElementScene::keyPressEvent manage key press event. | |
void | contextMenuEvent (QGraphicsSceneContextMenuEvent *event) override |
ElementScene::contextMenuEvent Display the context menu event, only if behavior are Normal. | |
void | drawForeground (QPainter *, const QRectF &) override |
ElementScene::drawForeground Draws the background of the editor, ie the hotspot indicator. | |
Private Member Functions | |
ElementScene (const ElementScene &) | |
QRectF | elementContentBoundingRect (const ElementContent &) const |
ElementScene::elementContentBoundingRect. | |
ElementContent | loadContent (const QDomDocument &) |
ElementScene::loadContent Create and load the content describe in the xml document. | |
ElementContent | addContent (const ElementContent &) |
ElementScene::addContent Add content content to this element. | |
ElementContent | addContentAtPos (const ElementContent &, const QPointF &) |
ElementScene::addContentAtPos Add content content to this element. | |
void | addPrimitive (QGraphicsItem *) |
ElementScene::addPrimitive Add a primitive to the scene by wrapping it within an ElementPrimitiveDecorator group. | |
void | initPasteArea () |
ElementScene::initPasteArea Initializes the paste area. | |
void | centerElementToOrigine () |
ElementScene::centerElementToOrigine try to center better is possible the element to the scene (the calcul isn't optimal but work good) | |
Static Private Member Functions | |
static bool | zValueLessThan (QGraphicsItem *, QGraphicsItem *) |
ElementScene::zValueLessThan. | |
Private Attributes | |
ElementData | m_element_data |
QGIManager | m_qgi_manager |
ElementData. Actually in transition with old data storage. | |
QUndoStack | m_undo_stack |
ESEventInterface * | m_event_interface = nullptr |
Behavior | m_behavior |
QETElementEditor * | m_element_editor = nullptr |
QGraphicsRectItem * | m_paste_area |
QRectF | m_defined_paste_area |
QString | m_last_copied |
ElementPrimitiveDecorator * | m_decorator = nullptr |
Decorator item displayed when at least one item is selected. | |
int | m_x_grid |
int | m_y_grid |
QPointer< CustomElementGraphicPart > | m_single_selected_item |
QMutex * | m_decorator_lock |
Friends | |
class | ChangePropertiesCommand |
The ElementScene class This class is the canvas allowing the visual edition of an electrical element. It displays the various primitives composing the drawing of the element, the border due to its fixed size and its hotspot.
For add and remove item prefer use custom method addItems and removeItems instead of addItem and removeItem, because these methods emit signal partAdded and partRemoved.
ElementScene::ElementScene | ( | QETElementEditor * | editor, |
QObject * | parent = nullptr |
||
) |
ElementScene::ElementScene constructor.
editor | : Element editor concerned |
parent | : Widget parent |
|
override |
|
private |
|
private |
ElementScene::addContent Add content content to this element.
content | : content (= list of parts) to load |
|
private |
ElementScene::addContentAtPos Add content content to this element.
content | : content (= list of parts) to load |
pos | : Position of the upper left corner of the content after being added |
void ElementScene::addItems | ( | QVector< QGraphicsItem * > | items | ) |
ElementScene::addItems Add items to the scene and emit partsAdded. Prefer always use this method instead of QGraphicsScene::addItem even if you want to add one item, for gain the signal emission.
items |
|
private |
ElementScene::addPrimitive Add a primitive to the scene by wrapping it within an ElementPrimitiveDecorator group.
primitive |
ElementScene::Behavior ElementScene::behavior | ( | ) | const |
|
virtual |
ElementScene::boundingRectFromXml.
xml_document | : an XML document describing an element |
|
private |
ElementScene::centerElementToOrigine try to center better is possible the element to the scene (the calcul isn't optimal but work good)
void ElementScene::clearEventInterface | ( | ) |
ElementScene::clearEventInterface Clear the current event interface.
|
static |
ElementScene::clipboardMayContainElement.
bool ElementScene::containsTerminals | ( | ) | const |
ElementScene::containsTerminals.
|
overrideprotected |
ElementScene::contextMenuEvent Display the context menu event, only if behavior are Normal.
event |
void ElementScene::copy | ( | ) |
ElementScene::copy Handles the fact of copying the selection = exporting it as XML to the clipboard.
void ElementScene::cut | ( | ) |
ElementScene::cut Handles the fact of cutting the selection = exporting it in XML to the clipboard then deleting it.
|
overrideprotected |
ElementScene::drawForeground Draws the background of the editor, ie the hotspot indicator.
p | : The QPainter to use for drawing |
QETElementEditor * ElementScene::editor | ( | ) | const |
|
private |
ElementScene::elementContentBoundingRect.
content | : Content (= parts) of an element |
ElementData ElementScene::elementData | ( | ) |
|
signal |
QRectF ElementScene::elementSceneGeometricRect | ( | ) | const |
ElementScene::elementSceneGeometricRect.
|
virtual |
ElementScene::fromXml Imports the element described in an XML document. If a position is specified, the imported elements are positioned in such a way that the upper left corner of the smallest rectangle that can surround them all (the bounding rect) either at this position.
xml_document | : an XML document describing the element |
position | : The position of the imported parts |
consider_informations | : If true, additional information (dimensions, hotspot, etc.) will be taken into account |
content_ptr | : if this pointer to an ElementContent is different from 0, it will be filled with the content added to the element by the fromXml |
|
virtual |
to_paste | : Rectangle enclosing the parts to be glued |
|
private |
|
overrideprotected |
ElementScene::keyPressEvent manage key press event.
event |
|
private |
ElementScene::loadContent Create and load the content describe in the xml document.
xml_document | : xml dom document to analyze |
|
slot |
ElementScene::managePrimitivesGroups Ensure the decorator is adequately shown, hidden or updated so it always represents the current selection.
|
overrideprotected |
ElementScene::mouseDoubleClickEvent.
event |
|
overrideprotected |
e |
|
overrideprotected |
ElementScene::mousePressEvent.
e |
|
overrideprotected |
ElementScene::mouseReleaseEvent.
e |
|
signal |
Signal emitted when need zoomFit.
|
signal |
Signal emitted after one or several parts were added.
|
signal |
Signal emitted after one or several parts were removed.
|
signal |
Signal emitted when the zValue of one or several parts change.
|
signal |
Signal emitted when users have defined the copy/paste area.
|
virtual |
QGIManager & ElementScene::qgiManager | ( | ) |
void ElementScene::removeItems | ( | QVector< QGraphicsItem * > | items | ) |
ElementScene::removeItems Remove items from the scene and emit partsRemoved. Prefer always use this method instead of QGraphicsScene::removeItem even if you want to remove one item, for gain the signal emission.
items |
|
virtual |
ElementScene::reset Remove all QGraphicsItems in the scene and clear the undo stack.
|
virtual |
ElementScene::selectedContent.
void ElementScene::setBehavior | ( | ElementScene::Behavior | b | ) |
ElementScene::setBehavior Modify the current behavior of this scene.
b |
void ElementScene::setElementData | ( | ElementData | data | ) |
void ElementScene::setEventInterface | ( | ESEventInterface * | event_interface | ) |
ElementScene::setEventInterface Set a new event interface.
event_interface |
|
virtual |
x_g | : Horizontal grid size |
y_g | : Vertical grid size |
|
slot |
|
slot |
ElementScene::slot_deselectAll deselect all item.
|
slot |
ElementScene::slot_editAuthorInformations Starts a dialog to edit the additional information of this element. Concretely, this free field is intended to receive information on the author of the element, its license, etc.
|
slot |
ElementScene::slot_editNames Launch a dialog for edit the names of the edited element.
|
slot |
ElementScene::slot_editProperties Open dialog to edit the element properties.
|
slot |
|
slot |
ElementScene::slot_select Select the item in content, every others items in the scene are deselected.
content |
|
slot |
ElementScene::slot_selectAll Select all items.
QPointF ElementScene::snapToGrid | ( | QPointF | point | ) |
ElementScene::snapToGrid Rounds the coordinates of the point passed as a parameter so that this point is aligned with the grid.
point | : a reference to a QPointF. This object will be modified. |
|
slot |
ElementScene::stackAction Push the provided command on the undo stack.
command |
|
virtual |
ElementScene::toXml Export this element as a xml file.
all_parts | : (true by default) if true, export the entire element in xml, if false, only export the selected parts. |
QUndoStack & ElementScene::undoStack | ( | ) |
bool ElementScene::wasCopiedFromThisElement | ( | const QString & | clipboard_content | ) |
ElementScene::wasCopiedFromThisElement.
clipboard_content | : character string, probably coming from the clipboard. |
|
virtual |
|
virtual |
|
virtual |
options |
|
staticprivate |
item1 | : QGraphicsItem |
item2 | : QGraphicsItem |
|
friend |
|
private |
|
private |
Decorator item displayed when at least one item is selected.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
ElementData. Actually in transition with old data storage.
|
private |
|
private |
|
private |
|
private |