/*************************************************************************** * Copyright (C) 2008 by Peter Dahlberg * * pdahlberg@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef FIELDITEM_H #define FIELDITEM_H #include #include //! Ein abstraktes Feld GraphicsItem /** @author Peter Dahlberg */ class QPointF; class QGraphicsSceneWheelEvent; class SimulScene; class FieldItem :public QObject, public QGraphicsItem { Q_OBJECT public: FieldItem(); virtual ~FieldItem(); //! gibt das Rechteck des Feldes zurück virtual QRectF getRectF() const; //! alias für getRectF() QRectF rect() const; virtual QRectF boundingRect() const = 0; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) = 0; virtual QWidget* getDockWidget() const = 0; //! Prüft, ob ein allgemeines Item ein FiledItem ist /*! Die Liste der Item Typen wird in der Funktion definiert \param item Das zu pruefende Item */ static bool isFieldItem(QGraphicsItem *item); int getRotation(); protected: virtual void wheelEvent(QGraphicsSceneWheelEvent * event); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); QPointF myScenePos; int myRotation; QRectF sizeRect; SimulScene* mySimulScene; public slots: virtual void handleSceneChange(const QList & region); virtual void setScenePosX(double newXPos); virtual void setScenePosY(double newYPos); virtual void setRotation(int angle); public slots: //! setzt das rechteck des Widgets /*! \param rect Das neue QRectF */ virtual void setRectF ( QRectF rect ); //! alias für setRectF() /*! \param rect Das neue QRectF */ void setRect ( QRectF rect ); //! Breite des Item Rechtecks setzen /*! \param newWidth Die neue Breite */ virtual void setRectFWidth ( double newWidth ); //! Höhe des Item Rechtecks setzen /*! \param newHeight Die neue Höhe */ virtual void setRectFHeight ( double newHeight ); signals: void ScenePosChanged(QPointF newpos); void ScenePosXChanged(double newX); void ScenePosYChanged(double newY); void rotationChanged(int angle); void rotationChanged(); void heightChanged ( double height ); void widthChanged ( double width ); }; #endif