QElectroTech  0.70
Public Types | Public Slots | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
CrossRefItem Class Reference

The CrossRefItem class This clas provide an item, for show the cross reference, like the contacts linked to a coil. The item setpos automaticaly when parent move. All slave displayed in cross ref will be updated when folio position change in the project. It's the responsability of the master element to informe displayed slave are moved, by calling the slot By default master element is the parent graphics item of this Xref, but if the Xref must be snap to the label of master, the label become the parent of this Xref. This behavior can be changed at anytime by calling setProperties. More...

#include <crossrefitem.h>

Public Types

enum  { Type = UserType + 1009 }
 
enum  CONTACTS {
  NO = 1, NC = 2, NOC = 3, SW = 4,
  Power = 8, DelayOn = 16, DelayOff = 32, DelayOnOff = 64,
  Delay = 112
}
 

Public Slots

void updateProperties ()
 CrossRefItem::updateProperties update the curent properties. More...
 
void updateLabel ()
 CrossRefItem::updateLabel Update the content of the item. More...
 
void autoPos ()
 CrossRefItem::autoPos Calculate and set position automaticaly. More...
 

Public Member Functions

 CrossRefItem (Element *elmt)
 CrossRefItem::CrossRefItem. More...
 
 CrossRefItem (Element *elmt, DynamicElementTextItem *text)
 CrossRefItem::CrossRefItem. More...
 
 CrossRefItem (Element *elmt, ElementTextItemGroup *group)
 CrossRefItem::CrossRefItem. More...
 
 ~CrossRefItem () override
 CrossRefItem::~CrossRefItem Default destructor. More...
 
int type () const override
 
QRectF boundingRect () const override
 CrossRefItem::boundingRect. More...
 
QPainterPath shape () const override
 CrossRefItem::shape. More...
 
QString elementPositionText (const Element *elmt, const bool &add_prefix=false) const
 CrossRefItem::elementPositionText. More...
 

Protected Member Functions

bool sceneEvent (QEvent *event) override
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
 CrossRefItem::paint Paint this item. More...
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override
 CrossRefItem::mouseDoubleClickEvent. More...
 
void hoverEnterEvent (QGraphicsSceneHoverEvent *event) override
 
void hoverMoveEvent (QGraphicsSceneHoverEvent *event) override
 
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event) override
 

Private Member Functions

void init ()
 CrossRefItem::init init this Xref. More...
 
void setUpConnection ()
 CrossRefItem::setUpConnection Set up several connection to keep up to date the Xref. More...
 
void linkedChanged ()
 
void buildHeaderContact ()
 CrossRefItem::buildHeaderContact Draw the QPicture of m_hdr_no_ctc and m_hdr_nc_ctc. More...
 
void setUpCrossBoundingRect (QPainter &painter)
 CrossRefItem::setUpCrossBoundingRect Get the numbers of slaves elements linked to this parent element, for calculate the size of the cross bounding rect. The cross ref item is drawing according to the size of the cross bounding rect. More...
 
void drawAsCross (QPainter &painter)
 CrossRefItem::drawAsCross Draw this crossref with a cross. More...
 
void drawAsContacts (QPainter &painter)
 CrossRefItem::drawAsContacts Draw this crossref with symbolic contacts. More...
 
QRectF drawContact (QPainter &painter, int flags, Element *elmt)
 CrossRefItem::drawContact Draw one contact, the type of contact to draw is define in . More...
 
void fillCrossRef (QPainter &painter)
 CrossRefItem::fillCrossRef Fill the content of the cross ref. More...
 
void AddExtraInfo (QPainter &painter, const QString &)
 CrossRefItem::AddExtraInfo Add the comment info of the parent item if needed. More...
 
QList< Element * > NOElements () const
 CrossRefItem::NOElements. More...
 
QList< Element * > NCElements () const
 CrossRefItem::NCElements. More...
 

Private Attributes

Elementm_element
 
QRectF m_bounding_rect
 
QPicture m_drawing
 
QPicture m_hdr_no_ctc
 
QPicture m_hdr_nc_ctc
 
QPainterPath m_shape_path
 
XRefProperties m_properties
 
int m_drawed_contacts
 
QMap< Element *, QRectF > m_hovered_contacts_map
 
Elementm_hovered_contact = nullptr
 
DynamicElementTextItemm_text = nullptr
 
ElementTextItemGroupm_group = nullptr
 
QList< QMetaObject::Connection > m_slave_connection
 
QList< QMetaObject::Connection > m_update_connection
 

Detailed Description

The CrossRefItem class This clas provide an item, for show the cross reference, like the contacts linked to a coil. The item setpos automaticaly when parent move. All slave displayed in cross ref will be updated when folio position change in the project. It's the responsability of the master element to informe displayed slave are moved, by calling the slot By default master element is the parent graphics item of this Xref, but if the Xref must be snap to the label of master, the label become the parent of this Xref. This behavior can be changed at anytime by calling setProperties.

Definition at line 40 of file crossrefitem.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 55 of file crossrefitem.h.

◆ CONTACTS

Enumerator
NO 
NC 
NOC 
SW 
Power 
DelayOn 
DelayOff 
DelayOnOff 
Delay 

Definition at line 58 of file crossrefitem.h.

Constructor & Destructor Documentation

◆ CrossRefItem() [1/3]

CrossRefItem::CrossRefItem ( Element elmt)
explicit

CrossRefItem::CrossRefItem.

Parameters
elmt: element to display the cross ref

Definition at line 37 of file crossrefitem.cpp.

References init().

◆ CrossRefItem() [2/3]

CrossRefItem::CrossRefItem ( Element elmt,
DynamicElementTextItem text 
)
explicit

CrossRefItem::CrossRefItem.

Parameters
elmt: element to display the cross ref
text: If the Xref must be displayed under a text, the text.

Definition at line 47 of file crossrefitem.cpp.

References init().

◆ CrossRefItem() [3/3]

CrossRefItem::CrossRefItem ( Element elmt,
ElementTextItemGroup group 
)
explicit

CrossRefItem::CrossRefItem.

Parameters
elmt: element to display the cross ref
group: If the Xref must be displayed under a group, the group.

Definition at line 58 of file crossrefitem.cpp.

References init().

◆ ~CrossRefItem()

CrossRefItem::~CrossRefItem ( )
override

CrossRefItem::~CrossRefItem Default destructor.

Definition at line 68 of file crossrefitem.cpp.

Member Function Documentation

◆ AddExtraInfo()

void CrossRefItem::AddExtraInfo ( QPainter &  painter,
const QString &  type 
)
private

CrossRefItem::AddExtraInfo Add the comment info of the parent item if needed.

Parameters
painterpainter to use for draw the text
typetype of Info do be draw e.g. comment, location.

Definition at line 821 of file crossrefitem.cpp.

References boundingRect(), QetGraphicsItem::diagram(), QETApp::diagramTextsFont(), autonum::AssignVariables::formulaToLabel(), m_bounding_rect, m_element, m_shape_path, Element::rSequenceStruct(), and type().

◆ autoPos

void CrossRefItem::autoPos ( )
slot

◆ boundingRect()

QRectF CrossRefItem::boundingRect ( ) const
override

CrossRefItem::boundingRect.

Returns
the bounding rect of this item

Definition at line 129 of file crossrefitem.cpp.

References m_bounding_rect.

Referenced by MasterElement::aboutDeleteXref(), AddExtraInfo(), drawAsCross(), and MasterElement::XrefBoundingRect().

◆ buildHeaderContact()

void CrossRefItem::buildHeaderContact ( )
private

CrossRefItem::buildHeaderContact Draw the QPicture of m_hdr_no_ctc and m_hdr_nc_ctc.

Definition at line 393 of file crossrefitem.cpp.

References m_hdr_nc_ctc, and m_hdr_no_ctc.

Referenced by drawAsCross().

◆ drawAsContacts()

void CrossRefItem::drawAsContacts ( QPainter &  painter)
private

CrossRefItem::drawAsContacts Draw this crossref with symbolic contacts.

Parameters
painterpainter to use

Definition at line 528 of file crossrefitem.cpp.

References QET::Icons::br, DelayOff, DelayOn, DelayOnOff, drawContact(), Element::kindInformations(), Element::linkedElements(), m_bounding_rect, m_drawed_contacts, m_element, m_hovered_contacts_map, m_shape_path, NC, NO, Power, SW, and type().

Referenced by updateLabel().

◆ drawAsCross()

void CrossRefItem::drawAsCross ( QPainter &  painter)
private

CrossRefItem::drawAsCross Draw this crossref with a cross.

Parameters
painter,painterto use

Definition at line 498 of file crossrefitem.cpp.

References boundingRect(), QET::Icons::br, buildHeaderContact(), fillCrossRef(), header, m_bounding_rect, m_hdr_nc_ctc, m_hdr_no_ctc, m_hovered_contacts_map, and setUpCrossBoundingRect().

Referenced by updateLabel().

◆ drawContact()

QRectF CrossRefItem::drawContact ( QPainter &  painter,
int  flags,
Element elmt 
)
private

CrossRefItem::drawContact Draw one contact, the type of contact to draw is define in .

Parameters
painter,painterto use
flags,definehow to draw the contact (see enul CONTACTS)
elmt,theelement to display text (the position of the contact)
Returns
The bounding rect of the draw (contact + text)

take exemple of this code for display the terminal text

Definition at line 576 of file crossrefitem.cpp.

References Delay, DelayOff, DelayOn, DelayOnOff, elementPositionText(), m_drawed_contacts, m_hovered_contact, m_hovered_contacts_map, NC, NO, NOC, Power, and SW.

Referenced by drawAsContacts().

◆ elementPositionText()

QString CrossRefItem::elementPositionText ( const Element elmt,
const bool &  add_prefix = false 
) const

CrossRefItem::elementPositionText.

Parameters
elmt
Returns
the string corresponding to the position of in the diagram. if is true, prefix (for power and delay contact) is added to the poistion text.

Definition at line 147 of file crossrefitem.cpp.

References DiagramContext::contains(), QETProject::defaultXRefProperties(), QetGraphicsItem::diagram(), autonum::AssignVariables::formulaToLabel(), Element::kindInformations(), m_element, m_properties, XRefProperties::masterLabel(), XRefProperties::prefix(), and Diagram::project().

Referenced by drawContact(), fillCrossRef(), and setUpCrossBoundingRect().

◆ fillCrossRef()

void CrossRefItem::fillCrossRef ( QPainter &  painter)
private

CrossRefItem::fillCrossRef Fill the content of the cross ref.

Parameters
painterpainter to use.

Definition at line 760 of file crossrefitem.cpp.

References elementPositionText(), header, Element::isFree(), m_bounding_rect, m_element, m_hovered_contact, m_hovered_contacts_map, NCElements(), and NOElements().

Referenced by drawAsCross().

◆ hoverEnterEvent()

void CrossRefItem::hoverEnterEvent ( QGraphicsSceneHoverEvent *  event)
overrideprotected

Definition at line 303 of file crossrefitem.cpp.

References m_hovered_contact.

Referenced by sceneEvent().

◆ hoverLeaveEvent()

void CrossRefItem::hoverLeaveEvent ( QGraphicsSceneHoverEvent *  event)
overrideprotected

Definition at line 363 of file crossrefitem.cpp.

References m_hovered_contact, and updateLabel().

Referenced by sceneEvent().

◆ hoverMoveEvent()

void CrossRefItem::hoverMoveEvent ( QGraphicsSceneHoverEvent *  event)
overrideprotected

Definition at line 309 of file crossrefitem.cpp.

References m_hovered_contact, m_hovered_contacts_map, and updateLabel().

Referenced by sceneEvent().

◆ init()

void CrossRefItem::init ( )
private

◆ linkedChanged()

void CrossRefItem::linkedChanged ( )
private

Definition at line 370 of file crossrefitem.cpp.

References Element::linkedElements(), m_element, m_slave_connection, and updateLabel().

Referenced by init(), and setUpConnection().

◆ mouseDoubleClickEvent()

void CrossRefItem::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

CrossRefItem::mouseDoubleClickEvent.

Parameters
event

Definition at line 281 of file crossrefitem.cpp.

References QetGraphicsItem::diagram(), m_hovered_contact, and Diagram::showMe().

Referenced by sceneEvent().

◆ NCElements()

QList< Element * > CrossRefItem::NCElements ( ) const
private

CrossRefItem::NCElements.

Returns
The linked elements of wich are close or switch contact If linked element is a power contact, xref propertie is set to don't show power contact and this cross item must be drawed as cross, the element is not append in the list.

Definition at line 887 of file crossrefitem.cpp.

References XRefProperties::Cross, XRefProperties::displayHas(), Element::kindInformations(), Element::linkedElements(), m_element, m_properties, and XRefProperties::showPowerContact().

Referenced by fillCrossRef(), and setUpCrossBoundingRect().

◆ NOElements()

QList< Element * > CrossRefItem::NOElements ( ) const
private

CrossRefItem::NOElements.

Returns
The linked elements of wich are open or switch contact. If linked element is a power contact, xref propertie is set to don't show power contact and this cross item must be drawed as cross, the element is not append in the list.

Definition at line 857 of file crossrefitem.cpp.

References XRefProperties::Cross, XRefProperties::displayHas(), Element::kindInformations(), Element::linkedElements(), m_element, m_properties, and XRefProperties::showPowerContact().

Referenced by fillCrossRef(), and setUpCrossBoundingRect().

◆ paint()

void CrossRefItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget 
)
overrideprotected

CrossRefItem::paint Paint this item.

Parameters
painter
option
widget

Definition at line 271 of file crossrefitem.cpp.

References m_drawing.

◆ sceneEvent()

bool CrossRefItem::sceneEvent ( QEvent *  event)
overrideprotected

◆ setUpConnection()

void CrossRefItem::setUpConnection ( )
private

◆ setUpCrossBoundingRect()

void CrossRefItem::setUpCrossBoundingRect ( QPainter &  painter)
private

CrossRefItem::setUpCrossBoundingRect Get the numbers of slaves elements linked to this parent element, for calculate the size of the cross bounding rect. The cross ref item is drawing according to the size of the cross bounding rect.

Definition at line 441 of file crossrefitem.cpp.

References cross_min_heigth, elementPositionText(), header, Element::isFree(), m_bounding_rect, m_element, m_shape_path, NCElements(), and NOElements().

Referenced by drawAsCross().

◆ shape()

QPainterPath CrossRefItem::shape ( ) const
override

CrossRefItem::shape.

Returns
the shape of this item

Definition at line 137 of file crossrefitem.cpp.

References m_shape_path.

◆ type()

int CrossRefItem::type ( ) const
inlineoverride

Definition at line 56 of file crossrefitem.h.

References Type.

Referenced by AddExtraInfo(), and drawAsContacts().

◆ updateLabel

void CrossRefItem::updateLabel ( )
slot

◆ updateProperties

void CrossRefItem::updateProperties ( )
slot

Member Data Documentation

◆ m_bounding_rect

QRectF CrossRefItem::m_bounding_rect
private

◆ m_drawed_contacts

int CrossRefItem::m_drawed_contacts
private

Definition at line 106 of file crossrefitem.h.

Referenced by drawAsContacts(), and drawContact().

◆ m_drawing

QPicture CrossRefItem::m_drawing
private

Definition at line 103 of file crossrefitem.h.

Referenced by paint(), and updateLabel().

◆ m_element

Element* CrossRefItem::m_element
private

◆ m_group

ElementTextItemGroup* CrossRefItem::m_group = nullptr
private

Definition at line 110 of file crossrefitem.h.

Referenced by sceneEvent(), setUpConnection(), and updateProperties().

◆ m_hdr_nc_ctc

QPicture CrossRefItem::m_hdr_nc_ctc
private

Definition at line 103 of file crossrefitem.h.

Referenced by buildHeaderContact(), and drawAsCross().

◆ m_hdr_no_ctc

QPicture CrossRefItem::m_hdr_no_ctc
private

Definition at line 103 of file crossrefitem.h.

Referenced by buildHeaderContact(), and drawAsCross().

◆ m_hovered_contact

Element* CrossRefItem::m_hovered_contact = nullptr
private

◆ m_hovered_contacts_map

QMap<Element *, QRectF> CrossRefItem::m_hovered_contacts_map
private

◆ m_properties

XRefProperties CrossRefItem::m_properties
private

◆ m_shape_path

QPainterPath CrossRefItem::m_shape_path
private

◆ m_slave_connection

QList<QMetaObject::Connection> CrossRefItem::m_slave_connection
private

Definition at line 111 of file crossrefitem.h.

Referenced by linkedChanged().

◆ m_text

DynamicElementTextItem* CrossRefItem::m_text = nullptr
private

Definition at line 109 of file crossrefitem.h.

Referenced by setUpConnection(), and updateProperties().

◆ m_update_connection

QList<QMetaObject::Connection> CrossRefItem::m_update_connection
private

Definition at line 112 of file crossrefitem.h.

Referenced by setUpConnection().


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