QElectroTech  0.70
Public Types | Signals | Public Member Functions | Protected Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
PartRectangle Class Reference

#include <partrectangle.h>

Public Types

enum  { Type = UserType + 1109 }
 
- 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 rectChanged ()
 
void XRadiusChanged ()
 
void YRadiusChanged ()
 

Public Member Functions

 PartRectangle (QETElementEditor *, QGraphicsItem *parent=nullptr)
 PartRectangle::PartRectangle Constructor. More...
 
 ~PartRectangle () override
 PartRectangle::~PartRectangle. More...
 
int type () const override
 
void paint (QPainter *, const QStyleOptionGraphicsItem *, QWidget *=nullptr) override
 PartRectangle::paint Draw this Rectangle. More...
 
QString name () const override
 
QString xmlName () const override
 
const QDomElement toXml (QDomDocument &) const override
 PartRectangle::toXml Export this rectangle in xml. More...
 
void fromXml (const QDomElement &) override
 PartRectangle::fromXml Import the properties of this rectangle from a xml element. More...
 
QRectF rect () const
 
void setRect (const QRectF &rect)
 PartRectangle::setRect Sets the item's rectangle to be the given rectangle. More...
 
qreal XRadius () const
 
void setXRadius (qreal X)
 
qreal YRadius () const
 
void setYRadius (qreal Y)
 
QRectF sceneGeometricRect () const override
 PartRectangle::sceneGeometricRect. More...
 
virtual QPointF sceneTopLeft () const
 PartRectangle::sceneTopLeft. More...
 
QPainterPath shape () const override
 PartRectangle::shape. More...
 
QPainterPath shadowShape () const override
 
QRectF boundingRect () const override
 PartRectangle::boundingRect. More...
 
bool isUseless () const override
 PartRectangle::isUseless. More...
 
void startUserTransformation (const QRectF &) override
 PartRectangle::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
 PartRectangle::handleUserTransformation Handle the user-induced transformation from initial_selection_rect to new_selection_rect. More...
 
- 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 QETElementEditorelementEditor () const
 
virtual void updateCurrentPartEditor () const
 
virtual ElementSceneelementScene () const
 
virtual QUndoStack & undoStack () const
 
virtual QGraphicsItem * toItem ()
 
virtual QET::ScalingMethod preferredScalingMethod () const
 

Protected Member Functions

void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override
 PartRectangle::mouseReleaseEvent Handle mouse release event. More...
 
QVariant itemChange (GraphicsItemChange change, const QVariant &value) override
 PartRectangle::itemChange. More...
 
bool sceneEventFilter (QGraphicsItem *watched, QEvent *event) override
 PartRectangle::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

QRectF rect
 PartRectangle::rect. More...
 
qreal xRadius
 
qreal yRadius
 
- Properties inherited from CustomElementGraphicPart
LineStyle line_style
 
LineWeight line_weight
 
Filling filling
 
Color color
 
bool antialias
 

Private Member Functions

 PartRectangle (const PartRectangle &)
 
void switchResizeMode ()
 PartRectangle::switchResizeMode. More...
 
void adjusteHandlerPos ()
 PartRectangle::adjusteHandlerPos. More...
 
void handlerMousePressEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
 PartRectangle::handlerMousePressEvent. More...
 
void handlerMouseMoveEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
 PartRectangle::handlerMouseMoveEvent. More...
 
void handlerMouseReleaseEvent (QetGraphicsHandlerItem *qghi, QGraphicsSceneMouseEvent *event)
 
void sceneSelectionChanged ()
 PartRectangle::sceneSelectionChanged When the scene selection change, if there are several primitive selected, we remove the handler of this item. More...
 
void addHandler ()
 PartRectangle::addHandler Add handlers for this item. More...
 
void removeHandler ()
 PartRectangle::removeHandler Remove the handlers of this item. More...
 

Private Attributes

QRectF m_rect
 
QRectF m_old_rect
 
QList< QPointF > saved_points_
 
int m_resize_mode = 1
 
int m_vector_index = -1
 
QVector< QetGraphicsHandlerItem * > m_handler_vector
 
qreal m_xRadius = 0
 
qreal m_yRadius = 0
 
qreal m_old_xRadius
 
qreal m_old_yRadius
 
bool m_modifie_radius_equaly = false
 

Additional Inherited Members

- Static Public Member Functions inherited from CustomElementGraphicPart
static void drawCross (const QPointF &center, QPainter *painter)
 CustomElementGraphicPart::drawCross Draw a cross at pos center. More...
 
- Protected Attributes inherited from CustomElementGraphicPart
bool m_hovered
 

Detailed Description

This class represents a rectangle primitive which may be used to compose the drawing of an electrical element within the element editor. All coordinates is in item coordinate, except pos()

Definition at line 30 of file partrectangle.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
Type 

Definition at line 53 of file partrectangle.h.

Constructor & Destructor Documentation

◆ PartRectangle() [1/2]

PartRectangle::PartRectangle ( QETElementEditor editor,
QGraphicsItem *  parent = nullptr 
)

PartRectangle::PartRectangle Constructor.

Parameters
editorthe QETElementEditor of this item
parentparent item

Definition at line 30 of file partrectangle.cpp.

◆ ~PartRectangle()

PartRectangle::~PartRectangle ( )
override

PartRectangle::~PartRectangle.

Definition at line 37 of file partrectangle.cpp.

References removeHandler().

◆ PartRectangle() [2/2]

PartRectangle::PartRectangle ( const PartRectangle )
private

Member Function Documentation

◆ addHandler()

void PartRectangle::addHandler ( )
private

◆ adjusteHandlerPos()

void PartRectangle::adjusteHandlerPos ( )
private

◆ boundingRect()

QRectF PartRectangle::boundingRect ( ) const
override

PartRectangle::boundingRect.

Returns
Bounding rectangle this part can fit into

Definition at line 213 of file partrectangle.cpp.

References m_rect, CustomElementGraphicPart::penWeight(), and SHADOWS_HEIGHT.

Referenced by sceneGeometricRect().

◆ fromXml()

void PartRectangle::fromXml ( const QDomElement &  qde)
overridevirtual

PartRectangle::fromXml Import the properties of this rectangle from a xml element.

Parameters
qde: Xml document to use.

Implements CustomElementPart.

Definition at line 111 of file partrectangle.cpp.

References rect(), setRect(), setXRadius(), setYRadius(), and CustomElementGraphicPart::stylesFromXml().

◆ handlerMouseMoveEvent()

void PartRectangle::handlerMouseMoveEvent ( QetGraphicsHandlerItem qghi,
QGraphicsSceneMouseEvent *  event 
)
private

◆ handlerMousePressEvent()

void PartRectangle::handlerMousePressEvent ( QetGraphicsHandlerItem qghi,
QGraphicsSceneMouseEvent *  event 
)
private

◆ handlerMouseReleaseEvent()

void PartRectangle::handlerMouseReleaseEvent ( QetGraphicsHandlerItem qghi,
QGraphicsSceneMouseEvent *  event 
)
private

◆ handleUserTransformation()

void PartRectangle::handleUserTransformation ( const QRectF &  initial_selection_rect,
const QRectF &  new_selection_rect 
)
overridevirtual

PartRectangle::handleUserTransformation Handle the user-induced transformation from initial_selection_rect to new_selection_rect.

Parameters
initial_selection_rect
new_selection_rect

Implements CustomElementPart.

Definition at line 255 of file partrectangle.cpp.

References CustomElementPart::mapPoints(), saved_points_, and setRect().

◆ isUseless()

bool PartRectangle::isUseless ( ) const
overridevirtual

PartRectangle::isUseless.

Returns
true if this part is irrelevant and does not deserve to be Retained / registered. An rectangle is relevant when he's not null.

Implements CustomElementPart.

Definition at line 231 of file partrectangle.cpp.

References rect().

◆ itemChange()

QVariant PartRectangle::itemChange ( GraphicsItemChange  change,
const QVariant &  value 
)
overrideprotected

PartRectangle::itemChange.

Parameters
change
value
Returns

Definition at line 280 of file partrectangle.cpp.

References addHandler(), adjusteHandlerPos(), removeHandler(), and sceneSelectionChanged().

◆ mouseReleaseEvent()

void PartRectangle::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
overrideprotected

PartRectangle::mouseReleaseEvent Handle mouse release event.

Parameters
event

Definition at line 266 of file partrectangle.cpp.

References CustomElementGraphicPart::mouseReleaseEvent(), and switchResizeMode().

◆ name()

QString PartRectangle::name ( ) const
inlineoverridevirtual
Returns
the name of the primitive

Implements CustomElementPart.

Definition at line 60 of file partrectangle.h.

References QET::Icons::tr.

◆ paint()

void PartRectangle::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  options,
QWidget *  widget = nullptr 
)
override

◆ rect()

QRectF PartRectangle::rect ( ) const

◆ rectChanged

void PartRectangle::rectChanged ( )
signal

◆ removeHandler()

void PartRectangle::removeHandler ( )
private

PartRectangle::removeHandler Remove the handlers of this item.

Definition at line 544 of file partrectangle.cpp.

References m_handler_vector.

Referenced by itemChange(), sceneSelectionChanged(), and ~PartRectangle().

◆ sceneEventFilter()

bool PartRectangle::sceneEventFilter ( QGraphicsItem *  watched,
QEvent *  event 
)
overrideprotected

◆ sceneGeometricRect()

QRectF PartRectangle::sceneGeometricRect ( ) const
overridevirtual

PartRectangle::sceneGeometricRect.

Returns
the minimum, margin-less rectangle this part can fit into, in scene coordinates. It is different from boundingRect() because it is not supposed to imply any margin, and it is different from shape because it is a regular rectangle, not a complex shape.

Implements CustomElementPart.

Definition at line 170 of file partrectangle.cpp.

References boundingRect(), and rect().

◆ sceneSelectionChanged()

void PartRectangle::sceneSelectionChanged ( )
private

PartRectangle::sceneSelectionChanged When the scene selection change, if there are several primitive selected, we remove the handler of this item.

Definition at line 502 of file partrectangle.cpp.

References addHandler(), and removeHandler().

Referenced by itemChange().

◆ sceneTopLeft()

QPointF PartRectangle::sceneTopLeft ( ) const
virtual

PartRectangle::sceneTopLeft.

Returns
the top left of rectangle, in scene coordinate

Definition at line 178 of file partrectangle.cpp.

References rect().

Referenced by toXml().

◆ setRect()

void PartRectangle::setRect ( const QRectF &  rect)

PartRectangle::setRect Sets the item's rectangle to be the given rectangle.

Parameters
rect

Definition at line 138 of file partrectangle.cpp.

References adjusteHandlerPos(), m_rect, rect(), and rectChanged().

Referenced by fromXml(), handlerMouseMoveEvent(), and handleUserTransformation().

◆ setXRadius()

void PartRectangle::setXRadius ( qreal  X)

Definition at line 147 of file partrectangle.cpp.

References adjusteHandlerPos(), m_xRadius, and XRadiusChanged().

Referenced by fromXml(), and handlerMouseMoveEvent().

◆ setYRadius()

void PartRectangle::setYRadius ( qreal  Y)

Definition at line 155 of file partrectangle.cpp.

References adjusteHandlerPos(), m_yRadius, and YRadiusChanged().

Referenced by fromXml(), and handlerMouseMoveEvent().

◆ shadowShape()

QPainterPath PartRectangle::shadowShape ( ) const
overridevirtual

◆ shape()

QPainterPath PartRectangle::shape ( ) const
override

◆ startUserTransformation()

void PartRectangle::startUserTransformation ( const QRectF &  initial_selection_rect)
overridevirtual

PartRectangle::startUserTransformation Start the user-induced transformation, provided this primitive is contained within the initial_selection_rect bounding rectangle.

Parameters
initial_selection_rect

Implements CustomElementPart.

Definition at line 241 of file partrectangle.cpp.

References rect(), and saved_points_.

◆ switchResizeMode()

void PartRectangle::switchResizeMode ( )
private

◆ toXml()

const QDomElement PartRectangle::toXml ( QDomDocument &  xml_document) const
overridevirtual

PartRectangle::toXml Export this rectangle in xml.

Parameters
xml_document: Xml document to use for create the xml element.
Returns
an xml element that describe this ellipse

Implements CustomElementPart.

Definition at line 80 of file partrectangle.cpp.

References m_rect, m_xRadius, m_yRadius, rect(), sceneTopLeft(), and CustomElementGraphicPart::stylesToXml().

◆ type()

int PartRectangle::type ( ) const
inlineoverride

Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartRectangle.

Returns
the QGraphicsItem type

Definition at line 58 of file partrectangle.h.

References Type.

◆ xmlName()

QString PartRectangle::xmlName ( ) const
inlineoverridevirtual
Returns
the name that will be used as XML tag when exporting the primitive

Implements CustomElementPart.

Definition at line 62 of file partrectangle.h.

◆ XRadius()

qreal PartRectangle::XRadius ( ) const
inline

Definition at line 68 of file partrectangle.h.

References m_xRadius.

Referenced by RectangleEditor::editingFinished(), and RectangleEditor::updateForm().

◆ XRadiusChanged

void PartRectangle::XRadiusChanged ( )
signal

◆ YRadius()

qreal PartRectangle::YRadius ( ) const
inline

Definition at line 70 of file partrectangle.h.

References m_yRadius.

Referenced by RectangleEditor::editingFinished(), and RectangleEditor::updateForm().

◆ YRadiusChanged

void PartRectangle::YRadiusChanged ( )
signal

Member Data Documentation

◆ m_handler_vector

QVector<QetGraphicsHandlerItem *> PartRectangle::m_handler_vector
private

◆ m_modifie_radius_equaly

bool PartRectangle::m_modifie_radius_equaly = false
private

◆ m_old_rect

QRectF PartRectangle::m_old_rect
private

Definition at line 101 of file partrectangle.h.

Referenced by handlerMousePressEvent(), and handlerMouseReleaseEvent().

◆ m_old_xRadius

qreal PartRectangle::m_old_xRadius
private

Definition at line 108 of file partrectangle.h.

Referenced by handlerMousePressEvent(), and handlerMouseReleaseEvent().

◆ m_old_yRadius

qreal PartRectangle::m_old_yRadius
private

Definition at line 108 of file partrectangle.h.

Referenced by handlerMousePressEvent(), and handlerMouseReleaseEvent().

◆ m_rect

QRectF PartRectangle::m_rect
private

◆ m_resize_mode

int PartRectangle::m_resize_mode = 1
private

◆ m_vector_index

int PartRectangle::m_vector_index = -1
private

◆ m_xRadius

qreal PartRectangle::m_xRadius = 0
private

◆ m_yRadius

qreal PartRectangle::m_yRadius = 0
private

◆ saved_points_

QList<QPointF> PartRectangle::saved_points_
private

Definition at line 103 of file partrectangle.h.

Referenced by handleUserTransformation(), and startUserTransformation().

Property Documentation

◆ rect

QRectF PartRectangle::rect
readwrite

PartRectangle::rect.

Returns
: Returns the item's rectangle.

Definition at line 34 of file partrectangle.h.

Referenced by RectangleEditor::editingFinished(), and ESEventAddRect::mouseMoveEvent().

◆ xRadius

qreal PartRectangle::xRadius
readwrite

Definition at line 35 of file partrectangle.h.

◆ yRadius

qreal PartRectangle::yRadius
readwrite

Definition at line 36 of file partrectangle.h.


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