krita/ui

kis_shape_selection.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (c) 2007 Sven Langkamp <sven.langkamp@gmail.com>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #ifndef KIS_SHAPE_SELECTION_H
00019 #define KIS_SHAPE_SELECTION_H
00020 
00021 #include <KoShapeLayer.h>
00022 #include <KoShapeFactory.h>
00023 
00024 #include <kis_selection_component.h>
00025 #include <kis_types.h>
00026 
00027 #include <krita_export.h>
00028 
00029 class KoStore;
00030 class KisShapeSelectionCanvas;
00031 
00035 class KRITAUI_EXPORT KisShapeSelection : public KoShapeLayer, public KisSelectionComponent
00036 {
00037 public:
00038 
00039     KisShapeSelection(KisImageWSP image, KisSelectionSP selection);
00040 
00041     virtual ~KisShapeSelection();
00042 
00043     KisShapeSelection(const KisShapeSelection& rhs);
00044 
00045     KisSelectionComponent* clone();
00046 
00047     bool saveSelection(KoStore * store) const;
00048 
00049     bool loadSelection(KoStore * store);
00056     virtual void renderToProjection(KisSelection* projection);
00057     virtual void renderToProjection(KisSelection* projection, const QRect& r);
00058 
00059     virtual void setDirty();
00060 
00061     void addChild(KoShape *object);
00062     void removeChild(KoShape *object);
00063 
00064     virtual QPainterPath selectionOutline();
00065 
00066     KoShapeManager *shapeManager() const;
00067 
00068 protected:
00069 
00070     virtual void paintComponent(QPainter& painter, const KoViewConverter& converter);
00071 
00072 private:
00073 
00074     void renderSelection(KisSelection* projection, const QRect& r);
00075 
00076     KisImageWSP m_image;
00077     QPainterPath m_outline;
00078     bool m_dirty;
00079     KisShapeSelectionCanvas* m_canvas;
00080 
00081     friend class KisShapeSelectionModel;
00082 };
00083 
00084 
00085 class KRITAUI_EXPORT KisShapeSelectionFactory : public KoShapeFactory
00086 {
00087     Q_OBJECT
00088 public:
00089 
00090     using KoShapeFactory::createDefaultShape;
00091     using KoShapeFactory::createShape;
00092 
00093     KisShapeSelectionFactory(QObject* parent);
00094     ~KisShapeSelectionFactory() {}
00095 
00096     KoShape* createDefaultShape() const;
00097     KoShape* createShape(const KoProperties* params) const;
00098 
00099     bool hidden() const {
00100         return true;
00101     }
00102 };
00103 
00104 #endif