//---------------------------------------------------------------------------- // $Id: TransferItem.hpp,v 1.4 2010/01/18 00:19:54 philw Exp $ //---------------------------------------------------------------------------- #ifndef TransferItemINCLUDED #define TransferItemINCLUDED #ifndef CallbackINCLUDED # include "Callback.hpp" #endif #ifndef SupplyINCLUDED # include "Supply.hpp" #endif #ifndef AccountItemINCLUDED #include "AccountItem.hpp" #endif #include #include #include #include #include #include class SimObj; class Slot; class LinkDisplayInfo; //---------------------------------------------------------------------------- // class // // A TransferItem is a derived QCanvasItem that represents a supply between two // accounts on the same simulation object as a Bezier line with an arrowhead // on the demand-side. // // In an ideal world this would have be derived from SupplyItem, since it // does represent a supply. However, a SupplyItem is QCanvasLine while this // is a QCanvasRectangle for drawing/updating purposes. //---------------------------------------------------------------------------- class TransferItem: public Q3CanvasRectangle { public: enum AccountRTTI { RIVERWARE_ITEM = 2000 }; TransferItem(Supply *supply, AccountItem *acct1, AccountItem *acct2, Q3Canvas *canvas); virtual ~TransferItem(); void update(); void scale(double sx, double sy); void show(); void hide(); Supply* supply() { return _supply; } void setStyle(const LinkDisplayInfo &info); bool hit( const QPoint&) const; virtual int rtti() const { return RIVERWARE_ITEM; } protected: QPoint closestPoint(const QPoint &e1, const QPoint &e2, const QPoint &p) const; void drawShape( QPainter & ); private: Supply *_supply; AccountItem *_supplyAccount; AccountItem *_destAccount; int _lineWidth; const int _ARC_HEIGHT; const int _ARC_WIDTH; Q3PointArray _points; Q3CanvasPolygon *_arrowhead; const int _ARROW_LENGTH; const int _ARROW_WIDTH; }; #endif