#include <mechanicsitem.h>
Inheritance diagram for MechanicsItem:


Public Types | |
| enum | SelectionMode { sm_move, sm_resize, sm_rotate } |
Public Slots | |
| void | rotateBy (double dtheta) |
| void | parentMoved () |
Signals | |
| void | moved () |
Public Member Functions | |
| MechanicsItem (MechanicsDocument *mechanicsDocument, bool newItem, const QString &id) | |
| virtual | ~MechanicsItem () |
| int | rtti () const |
| void | setSelectionMode (SelectionMode sm) |
| virtual void | setSelected (bool yes) |
| SelectionMode | selectionMode () const |
| virtual void | moveBy (double dx, double dy) |
| PositionInfo | absolutePosition () const |
| PositionInfo | relativePosition () const |
| MechanicsInfo * | mechanicsInfo () |
| CombinedMechanicsInfo * | mechanicsInfoCombined () |
| QRect | maxInnerRectangle (const QRect &outerRect) const |
| virtual ItemData | itemData () const |
| virtual bool | mousePressEvent (const EventInfo &eventInfo) |
| virtual bool | mouseReleaseEvent (const EventInfo &eventInfo) |
| virtual bool | mouseDoubleClickEvent (const EventInfo &eventInfo) |
| virtual bool | mouseMoveEvent (const EventInfo &eventInfo) |
| virtual bool | wheelEvent (const EventInfo &eventInfo) |
| virtual void | enterEvent () |
| virtual void | leaveEvent () |
Protected Slots | |
| void | updateMechanicsInfoCombined () |
Protected Member Functions | |
| virtual void | reparented (Item *oldItem, Item *newItem) |
| virtual void | childAdded (Item *child) |
| virtual void | childRemoved (Item *child) |
| virtual void | itemResized () |
| void | initPainter (QPainter &p) |
| void | deinitPainter (QPainter &p) |
| virtual void | dataChanged () |
| virtual void | itemPointsChanged () |
| void | updateCanvasPoints () |
Protected Attributes | |
| MechanicsDocument * | p_mechanicsDocument |
| PositionInfo | m_relativePosition |
| MechanicsInfo | m_mechanicsInfo |
| CombinedMechanicsInfo | m_mechanicsInfoCombined |
Definition at line 118 of file mechanicsitem.h.
| int MechanicsItem::rtti | ( | ) | const |
Returns the run-time identifier for the MechanicsItem
Definition at line 66 of file mechanicsitem.cpp.
| void MechanicsItem::setSelectionMode | ( | SelectionMode | sm | ) |
Sets the selection mode (sm_resize or sm_rotate). Note that setSelected also needs to be called to select the item.
Definition at line 72 of file mechanicsitem.cpp.
Referenced by CMMechItemMove::mousePressedInitial(), and CMMechItemMove::mouseReleased().
| void MechanicsItem::setSelected | ( | bool | yes | ) | [virtual] |
Sets the selected flag of the item to yes. selected or unselected will be emitted as appropriate
Reimplemented from Item.
Definition at line 81 of file mechanicsitem.cpp.
References Item::setSelected().
| SelectionMode MechanicsItem::selectionMode | ( | ) | const [inline] |
Definition at line 144 of file mechanicsitem.h.
Referenced by CMMechItemMove::mousePressedInitial().
| void MechanicsItem::moveBy | ( | double | dx, | |
| double | dy | |||
| ) | [virtual] |
Move the MechanicsItem by the given amount
Reimplemented from Item.
Definition at line 194 of file mechanicsitem.cpp.
References m_relativePosition, Item::moveBy(), moved(), PositionInfo::translate(), PositionInfo::x(), and PositionInfo::y().
Referenced by ChassisCircular2::advance(), and RigidBody::moveBy().
| PositionInfo MechanicsItem::absolutePosition | ( | ) | const |
Returns the absolute position on the canvas
Definition at line 103 of file mechanicsitem.cpp.
References absolutePosition(), m_relativePosition, and Item::p_parentItem.
Referenced by absolutePosition(), ChassisCircular2::advance(), deinitPainter(), initPainter(), maxInnerRectangle(), parentMoved(), reparented(), MechanicsItemOverlay::slotUpdateResizeHandles(), and updateCanvasPoints().
| PositionInfo MechanicsItem::relativePosition | ( | ) | const [inline] |
Returns the position relative to the parent item (or the absolute position if there is no parent item)
Definition at line 157 of file mechanicsitem.h.
References m_relativePosition.
| MechanicsInfo* MechanicsItem::mechanicsInfo | ( | ) | [inline] |
Returns the mechanics info for this item (so not taking into account that of attached children)
Definition at line 162 of file mechanicsitem.h.
References m_mechanicsInfo.
| CombinedMechanicsInfo* MechanicsItem::mechanicsInfoCombined | ( | ) | [inline] |
Returns the combined mechanics info for this item (which takes into account that of attached children).
Definition at line 167 of file mechanicsitem.h.
References m_mechanicsInfoCombined.
Referenced by RigidBody::updateRigidBodyInfo().
| QRect MechanicsItem::maxInnerRectangle | ( | const QRect & | outerRect | ) | const |
Returns the rectangle that can legitimately fit inside the given bounding rectangle, given this items current rotation. Legitimately means that whether this item is allowed to be distorted, inverted, resized, etc.
Definition at line 290 of file mechanicsitem.cpp.
References absolutePosition(), Item::height(), and Item::width().
| void MechanicsItem::rotateBy | ( | double | dtheta | ) | [slot] |
Rotate the item by the given amount (in radians)
Definition at line 185 of file mechanicsitem.cpp.
References m_relativePosition, moved(), PositionInfo::rotate(), updateCanvasPoints(), and updateMechanicsInfoCombined().
Referenced by ChassisCircular2::advance(), and RigidBody::rotateBy().
| void MechanicsItem::moved | ( | ) | [signal] |
Emitted when this item moves (translates or rotates)
Referenced by moveBy(), parentMoved(), reparented(), and rotateBy().
| void MechanicsItem::updateMechanicsInfoCombined | ( | ) | [protected, slot] |
Recalculate the combined mechanics info (e.g. when mass is changed, or child added)
Definition at line 202 of file mechanicsitem.cpp.
References Item::m_children, m_mechanicsInfo, m_mechanicsInfoCombined, MechanicsInfo::mass, MechanicsInfo::momentOfInertia, CombinedMechanicsInfo::x, PositionInfo::x(), CombinedMechanicsInfo::y, and PositionInfo::y().
Referenced by childAdded(), childRemoved(), dataChanged(), and rotateBy().
Reinherit this function if you want to do anything with children. Called after the parent is changed, with the old parent and the new parent.
Reimplemented from Item.
Definition at line 113 of file mechanicsitem.cpp.
References absolutePosition(), m_relativePosition, moved(), parentMoved(), and updateCanvasPoints().
| void MechanicsItem::childAdded | ( | Item * | child | ) | [protected, virtual] |
Reinherit this function if you want to do anything with children. Called after a child has been added.
Reimplemented from Item.
Definition at line 134 of file mechanicsitem.cpp.
References updateMechanicsInfoCombined().
| void MechanicsItem::childRemoved | ( | Item * | child | ) | [protected, virtual] |
Reinherit this function if you want to do anything with children. Called after a child has been removed.
Reimplemented from Item.
Definition at line 145 of file mechanicsitem.cpp.
References updateMechanicsInfoCombined().
| virtual void MechanicsItem::itemResized | ( | ) | [inline, protected, virtual] |
Called when this item is resized, so that sub classes can do whatever
Reimplemented in ChassisCircular2.
Definition at line 211 of file mechanicsitem.h.
| void MechanicsItem::initPainter | ( | QPainter & | p | ) | [protected] |
Sets the correct orientation on the painter
Definition at line 335 of file mechanicsitem.cpp.
References absolutePosition(), PositionInfo::angle(), PositionInfo::x(), and PositionInfo::y().
Referenced by ChassisCircular2::drawShape().
| void MechanicsItem::deinitPainter | ( | QPainter & | p | ) | [protected] |
*Must* be called after calling initPainter, if initPainter was called
Definition at line 345 of file mechanicsitem.cpp.
References absolutePosition(), PositionInfo::angle(), PositionInfo::x(), and PositionInfo::y().
Referenced by ChassisCircular2::drawShape().
| virtual void MechanicsItem::itemPointsChanged | ( | ) | [inline, protected, virtual] |
Reinherit this function if you want to apply any sort of transformation to the item points
Reimplemented from Item.
Definition at line 221 of file mechanicsitem.h.
References updateCanvasPoints().
| void MechanicsItem::updateCanvasPoints | ( | ) | [protected] |
Calculates the setPoints required from the current m_itemPoints and the current position / angle
Definition at line 165 of file mechanicsitem.cpp.
References absolutePosition(), Item::m_itemPoints, and Item::m_sizeRect.
Referenced by itemPointsChanged(), parentMoved(), reparented(), and rotateBy().
1.5.1