QSapecNG
 All Classes Functions Enumerations Properties
item.h
00001 /*
00002     QSapecNG - Qt based SapecNG GUI front-end
00003     Copyright (C) 2009, Michele Caini
00004 
00005     This program is free software: you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation, either version 3 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 #ifndef ITEM_H
00021 #define ITEM_H
00022 
00023 
00024 #include <QtGui/QGraphicsItem>
00025 #include <QtGui/QPen>
00026 
00027 
00028 class QGraphicsSceneMouseEvent;
00029 
00030 
00031 namespace qsapecng
00032 {
00033 
00034 
00035 class SchematicScene;
00036 
00037 
00038 class Item: public QGraphicsItem
00039 {
00040 
00041 public:
00042   Item(QGraphicsItem* parent = 0, SchematicScene* scene = 0);
00043   virtual ~Item() { }
00044 
00045   enum { Type = UserType + 1 };
00046   enum { OpacityFactor = 3 };
00047 
00048   enum ItemType {
00049       Std = Type,
00050       Wire,
00051       Label
00052     };
00053 
00054   virtual inline ItemType itemType() const { return Std; }
00055   virtual inline int type() const { return Type; }
00056 
00057   virtual void mirror();
00058   virtual void rotate();
00059   virtual void rotateBack();
00060 
00061   bool mirrored() const;
00062   bool rotated() const;
00063   uint angle() const;
00064 
00065   SchematicScene* schematicScene() const;
00066 
00067 protected:
00068   virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
00069   virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
00070 
00071 protected:
00072   qreal penWidth() const;
00073   QPen defaultPen_;
00074   QPen itemPen_;
00075 
00076 private:
00077   bool mirrored_;
00078   uint angle_;
00079 
00080 };
00081 
00082 
00083 }
00084 
00085 
00086 #endif // ITEM_H
 All Classes Functions Enumerations Properties