/***************************************************************************
 *   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 <QGraphicsItem>
#include <QList>
#include <QVariant>

//! Ein abstraktes Feld GraphicsItem
/**
	@author Peter Dahlberg <pdahlberg@gmail.com>
*/
class QPointF;
class QGraphicsSceneWheelEvent;
class SimulScene;
class FieldItem :public QObject, public QGraphicsItem {
	Q_OBJECT
	public:
		FieldItem();

		virtual ~FieldItem();


		//! gibt das Rechteck des Feldes zur&uuml;ck
		virtual QRectF getRectF() const;

		//!  alias f&uuml;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&uuml;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();

		virtual QList<QVariant> getSaveDataList() = 0;
		virtual void setSaveDataList(QList<QVariant> list) = 0;


	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<QRectF> & region);
		virtual void setScenePosX(double newXPos);
		virtual void setScenePosY(double newYPos);
		virtual void setRotation(int angle);
		void deleteMe();
		void toggleSelection();

	public slots:
		//! setzt das rechteck des Widgets
		/*!
			\param rect Das neue QRectF
		*/
		virtual void setRectF ( QRectF rect );

		//! alias f&uuml;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&ouml;he des Item Rechtecks setzen
		/*!
			\param newHeight Die neue H&ouml;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
