QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
MasterElement Class Reference

The MasterElement class This class is a custom element, with extended behavior to be a master element. Master element can be linked with slave element and display a cross ref item for know with what other element he is linked. More...

#include <masterelement.h>

Inheritance diagram for MasterElement:
Inheritance graph
Collaboration diagram for MasterElement:
Collaboration graph

Public Member Functions

 MasterElement (const ElementsLocation &, QGraphicsItem *=nullptr, int *=nullptr)
 MasterElement::MasterElement Default constructor.
 ~MasterElement () override
 MasterElement::~MasterElement default destructor.
void linkToElement (Element *elmt) override
 MasterElement::linkToElement Link this master to another element For this class element must be a slave.
void unlinkAllElements () override
 MasterElement::unlinkAllElements Unlink all of the element in the QList connected_elements.
void unlinkElement (Element *elmt) override
 MasterElement::unlinkElement Unlink the given element in parameter.
void initLink (QETProject *project) override
 MasterElement::initLink.
QRectF XrefBoundingRect () const
 MasterElement::XrefBoundingRect.
ContactUsage contactUsage () const
ContactUsage contactCapacity () const
 MasterElement::contactCapacity The contacts this master declares it provides, by type, summed over its contact groups. A group stands for contactCount contacts of its type. Returns an empty tally when the element declares no groups, which is the case for every element in the standard collection today – callers use that to decide whether a capacity is worth showing at all.
bool isFull () const
 MasterElement::isFull.
Public Member Functions inherited from Element
 Element (const ElementsLocation &location, QGraphicsItem *=nullptr, int *state=nullptr, Element::kind link_type=Element::Simple)
 Element::Element.
 ~Element () override
 Element::~Element.
int type () const override
QList< Terminal * > terminals () const
 Element::terminals.
QList< Conductor * > conductors () const
 Element::conductors.
QList< QPair< Terminal *, Terminal * > > AlignedFreeTerminals () const
 Element::AlignedFreeTerminals.
DiagramContext elementInformations () const
virtual void setElementInformations (DiagramContext dc)
 Element::setElementInformations Set new information for this element. If new information is different of current infotmation emit elementInfoChange.
ElementData elementData () const
 Element::elementData.
void setElementData (ElementData data)
 Element::setElementData Set new data for this element. If m_information of data is changed, emit elementInfoChange.
DiagramContext kindInformations () const
 kindInformations
autonum::sequentialNumbers sequenceStruct () const
autonum::sequentialNumbersrSequenceStruct ()
void setUpFormula (bool code_letter=true, QUndoCommand *parent_undo=nullptr)
 Element::setUpFormula Set up the formula used to create the label of this element.
void setPrefix (QString)
 Element::setPrefix set Element Prefix.
QString getPrefix () const
 Element::getPrefix get Element Prefix.
void freezeLabel (bool freeze)
 Element::freezeLabel Freeze this element label.
bool isFreezeLabel () const
void freezeNewAddedElement ()
 Element::freezeNewAddedElement Freeze this label if needed.
QString actualLabel ()
 Element::actualLabel Always return the current label to be displayed. This function is useful when label is based on formula, because label can change at any time.
QString name () const override
 Element::name.
ElementsLocation location () const
virtual void setHighlighted (bool)
void displayHelpLine (bool b=true)
 Element::displayHelpLine Display the help line of each terminal if b is true.
QSize size () const
QPixmap pixmap ()
 Element::pixmap.
QPoint setHotspot (QPoint)
QPoint hotspot () const
void editProperty () override
virtual bool fromXml (QDomElement &, QHash< int, Terminal * > &)
 Element::fromXml Import the parameters of this element from a xml document. When call this function ensure this element is already in a scene, because the dynamic text item and element text item group (in the xml file) are created in this function and need a diagram for create their Xref, when this element is linked to another. If not the Xref can be not displayed, until the next call of update Xref of the group or text item.
virtual QDomElement toXml (QDomDocument &, QHash< Terminal *, int > &) const
 Element::toXml Allows to export the element in XML.
QUuid uuid () const
 Element::uuid.
int orientation () const
void addDynamicTextItem (DynamicElementTextItem *deti=nullptr)
 Element::addDynamiqueTextItem Add deti as a dynamic text item of this element, deti is reparented to this If deti is null, a new DynamicElementTextItem is created and added to this element.
void removeDynamicTextItem (DynamicElementTextItem *deti)
 Element::removeDynamicTextItem Remove deti, no matter if is a child of this element or a child of a group of this element. Set he parent item of deti to 0, deti is not deleted.
QList< DynamicElementTextItem * > dynamicTextItems () const
 Element::dynamicTextItems.
ElementTextItemGroupaddTextGroup (const QString &name)
 Element::addTextGroup Create and add an element text item group to this element. If this element already have a group with the same name, then name will renamed to name1 or name2 etc....
void addTextGroup (ElementTextItemGroup *group)
 Element::addTextGroup.
void removeTextGroup (ElementTextItemGroup *group)
 Element::removeTextGroup Remove the text group group from this element, and set the parent of group to 0. group is not deleted. All texts owned by the group will be reparented to this element.
ElementTextItemGrouptextGroup (const QString &name) const
 Element::textGroup.
QList< ElementTextItemGroup * > textGroups () const
 Element::textGroups.
bool addTextToGroup (DynamicElementTextItem *text, ElementTextItemGroup *group)
 Element::addTextToGroup Add the text text to the group group; If group isn't owned by this element return false. The text must be a text of this element.
bool removeTextFromGroup (DynamicElementTextItem *text, ElementTextItemGroup *group)
 Element::removeTextFromGroup Remove the text text from the group group, en reparent text to this element.
bool isFree () const
QList< Element * > linkedElements ()
 Element::linkedElements.
int groupIndexForElement (Element *elmt) const
 Element::groupIndexForElement Returns the group index assigned to the given linked element. For slave elements, this indicates which contact group of the master this slave is assigned to.
void setGroupIndexForElement (Element *elmt, int index)
 Element::setGroupIndexForElement Sets the group index for a linked element.
virtual kind linkType () const
 linkType use elementData function instead
QString linkTypeToString () const
 linkTypeToString use elementData function instead
void newUuid ()
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override
 Element::paint.
QRectF boundingRect () const override
QList< QPointF > plcTablePositions () const
 Positions where the PLC IO table is drawn (from the .elmt file).
Public Member Functions inherited from QetGraphicsItem
 QetGraphicsItem (QGraphicsItem *parent=nullptr)
 ~QetGraphicsItem () override=0
Diagramdiagram () const
virtual void setPos (const QPointF &p)
virtual void setPos (qreal x, qreal y)
virtual bool isMovable () const
virtual void setMovable (bool movable)
bool isHovered () const
QPointF hoverMousePos () const
QET::GraphicsItemState state () const
 QetGraphicsItem::state.

Protected Member Functions

QVariant itemChange (GraphicsItemChange change, const QVariant &value) override
Protected Member Functions inherited from Element
void drawAxes (QPainter *, const QStyleOptionGraphicsItem *)
void setSize (int, int)
 Element::setSize Define the size of the element. The size must be a multiple of 10. If not, the dimensions indicated will be arrrondies to higher tens.
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
 Element::mouseMoveEvent.
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 Element::mouseReleaseEvent.
void hoverEnterEvent (QGraphicsSceneHoverEvent *) override
void hoverLeaveEvent (QGraphicsSceneHoverEvent *) override
void drawPlcTable (QPainter *painter)
 Element::drawPlcTable Draw the PLC table directly from in-memory ElementData. This overlays the stale picture from the .elmt file with current data.
Protected Member Functions inherited from QetGraphicsItem
void mousePressEvent (QGraphicsSceneMouseEvent *event) override
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override
void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 QetGraphicsItem::mouseReleaseEvent handle mouse release click.
void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override
void hoverMoveEvent (QGraphicsSceneHoverEvent *event) override
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override

Private Member Functions

void xrefPropertiesChanged ()
void aboutDeleteXref ()
 MasterElement::aboutDeleteXref Check if Xref item must be displayed, if not, delete it. If Xref item is deleted or already not used (nullptr) return true; Else return false if Xref item is used NOTICE : Xref can display nothing but not be deleted so far. For example, if Xref is display has cross, only power contact are linked and option show power contact is disable, the cross isn't draw.
void connectSlavePositionUpdates (Element *slave)
 MasterElement::connectSlavePositionUpdates Connect slave xChanged/yChanged to master update() so the PLC table repaints in real-time when a slave moves on the diagram.
void disconnectSlavePositionUpdates (Element *slave)
 MasterElement::disconnectSlavePositionUpdates Disconnect slave position signals from master.

Private Attributes

CrossRefItemm_Xref_item = nullptr
bool m_first_scene_change = true
QHash< Element *, QMetaObject::Connection > m_slave_x_conn
QHash< Element *, QMetaObject::Connection > m_slave_y_conn

Additional Inherited Members

Public Types inherited from Element
enum  kind {
  Simple = 1 , NextReport = 2 , PreviousReport = 4 , AllReport = 6 ,
  Master = 8 , Slave = 16 , Terminale = 32 , Thumbnail = 64 ,
  ConductorDefinition = 128
}
 The kind enum Used to know the kind of this element (master, slave, report ect...). More...
enum  { Type = UserType + 1000 }
Public Slots inherited from Element
void updateConductorTexts ()
 Element::updateConductorTexts Slot that is triggered when a cable is * connected to or disconnected from a terminal on this component.
Signals inherited from Element
void linkedElementChanged ()
void elementInfoChange (DiagramContext old_info, DiagramContext new_info)
void textAdded (DynamicElementTextItem *deti)
void textRemoved (DynamicElementTextItem *deti)
void textsGroupAdded (ElementTextItemGroup *group)
void textsGroupAboutToBeRemoved (ElementTextItemGroup *group)
void textAddedToGroup (DynamicElementTextItem *text, ElementTextItemGroup *group)
void textRemovedFromGroup (DynamicElementTextItem *text, ElementTextItemGroup *group)
Static Public Member Functions inherited from Element
static bool valideXml (QDomElement &)
Static Public Member Functions inherited from QetGraphicsItem
static void showItem (QetGraphicsItem *item)
 QetGraphicsItem::QetGraphicsItem Default constructor.
Protected Attributes inherited from Element
QList< Element * > connected_elements
QList< LinkInfotmp_uuids_link
QHash< Element *, int > m_group_index_map
 Maps linked elements to their group index (for slave->master links).
QUuid m_uuid
kind m_link_type = Element::Simple
DiagramContext m_kind_informations
autonum::sequentialNumbers m_autoNum_seq
bool m_freeze_label = false
QString m_F_str
ElementsLocation m_location
QList< Terminal * > m_terminals
QPicture m_picture
QPicture m_low_zoom_picture
ElementData m_data
QList< QPointF > m_plc_table_positions
Protected Attributes inherited from QetGraphicsItem
bool is_movable_
bool m_first_move
bool snap_to_grid_
QPointF m_mouse_to_origin_movement
QET::GraphicsItemState m_state = QET:: GIOK

Detailed Description

The MasterElement class This class is a custom element, with extended behavior to be a master element. Master element can be linked with slave element and display a cross ref item for know with what other element he is linked.

Constructor & Destructor Documentation

◆ MasterElement()

MasterElement::MasterElement ( const ElementsLocation & location,
QGraphicsItem * qgi = nullptr,
int * state = nullptr )
explicit

MasterElement::MasterElement Default constructor.

Parameters
location: location of xml definition
qgi: parent QGraphicItem
state: int used to know if the creation of element have error
Here is the call graph for this function:

◆ ~MasterElement()

MasterElement::~MasterElement ( )
override

MasterElement::~MasterElement default destructor.

Here is the call graph for this function:

Member Function Documentation

◆ aboutDeleteXref()

void MasterElement::aboutDeleteXref ( )
private

MasterElement::aboutDeleteXref Check if Xref item must be displayed, if not, delete it. If Xref item is deleted or already not used (nullptr) return true; Else return false if Xref item is used NOTICE : Xref can display nothing but not be deleted so far. For example, if Xref is display has cross, only power contact are linked and option show power contact is disable, the cross isn't draw.

Returns
Here is the call graph for this function:
Here is the caller graph for this function:

◆ connectSlavePositionUpdates()

void MasterElement::connectSlavePositionUpdates ( Element * slave)
private

MasterElement::connectSlavePositionUpdates Connect slave xChanged/yChanged to master update() so the PLC table repaints in real-time when a slave moves on the diagram.

Parameters
slavethe slave element
Here is the call graph for this function:
Here is the caller graph for this function:

◆ contactCapacity()

ContactUsage MasterElement::contactCapacity ( ) const

MasterElement::contactCapacity The contacts this master declares it provides, by type, summed over its contact groups. A group stands for contactCount contacts of its type. Returns an empty tally when the element declares no groups, which is the case for every element in the standard collection today – callers use that to decide whether a capacity is worth showing at all.

Returns
the per type capacity
Here is the call graph for this function:
Here is the caller graph for this function:

◆ contactUsage()

ContactUsage MasterElement::contactUsage ( ) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disconnectSlavePositionUpdates()

void MasterElement::disconnectSlavePositionUpdates ( Element * slave)
private

MasterElement::disconnectSlavePositionUpdates Disconnect slave position signals from master.

Parameters
slavethe slave element
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initLink()

void MasterElement::initLink ( QETProject * project)
overridevirtual

MasterElement::initLink.

Parameters
projectCall init Link from custom element and after call update label for setup it.

Reimplemented from Element.

Here is the call graph for this function:

◆ isFull()

bool MasterElement::isFull ( ) const

MasterElement::isFull.

Returns
true if the master has reached its maximum number of slaves
Here is the call graph for this function:
Here is the caller graph for this function:

◆ itemChange()

QVariant MasterElement::itemChange ( GraphicsItemChange change,
const QVariant & value )
overrideprotected
Here is the call graph for this function:

◆ linkToElement()

void MasterElement::linkToElement ( Element * elmt)
overridevirtual

MasterElement::linkToElement Link this master to another element For this class element must be a slave.

Parameters
elmt

Reimplemented from Element.

Here is the call graph for this function:

◆ unlinkAllElements()

void MasterElement::unlinkAllElements ( )
overridevirtual

MasterElement::unlinkAllElements Unlink all of the element in the QList connected_elements.

Reimplemented from Element.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unlinkElement()

void MasterElement::unlinkElement ( Element * elmt)
overridevirtual

MasterElement::unlinkElement Unlink the given element in parameter.

Parameters
elmtelement to unlink from this

Reimplemented from Element.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ XrefBoundingRect()

QRectF MasterElement::XrefBoundingRect ( ) const

MasterElement::XrefBoundingRect.

Returns
The bounding rect of the Xref, if this element haven't got a xref, return a default QRectF
Here is the caller graph for this function:

◆ xrefPropertiesChanged()

void MasterElement::xrefPropertiesChanged ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_first_scene_change

bool MasterElement::m_first_scene_change = true
private

◆ m_slave_x_conn

QHash<Element*, QMetaObject::Connection> MasterElement::m_slave_x_conn
private

◆ m_slave_y_conn

QHash<Element*, QMetaObject::Connection> MasterElement::m_slave_y_conn
private

◆ m_Xref_item

CrossRefItem* MasterElement::m_Xref_item = nullptr
private

The documentation for this class was generated from the following files: