Warning: That file was not part of the compilation database. It may have many parsing errors.

1/***************************************************************************
2 * Copyright 2009, 2010 Stefan Majewsky <majewsky@gmx.net>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ***************************************************************************/
18
19#ifndef LIBPALA_SLICER_H
20#define LIBPALA_SLICER_H
21
22#if defined(MAKE_LIBPALA) || defined(USE_LOCAL_LIBPALA)
23# include "libpalamacros.h"
24#else
25# include <libpala/libpalamacros.h>
26#endif
27
28#include <QtCore/QObject>
29#include <QtCore/QVariant>
30
31namespace Pala
32{
33 class SlicerJob;
34 class SlicerMode;
35 class SlicerProperty;
36 class SlicerPropertySet;
37
38 /**
39 * \class Slicer slicer.h <Pala/Slicer>
40 * \brief Representation of a slicing algorithm.
41 *
42 * This class represents a slicing algorithm. It has to be subclassed by slicing plugin developers. Subclasses need to implement
43 * \li the constructor (where the slicer's properties and, if used, the modes have to be instantiated)
44 * \li the run() method (where the actual slicing is performed).
45 *
46 * Additionally, the class must be flagged as entry point into the plugin, with the following code:
47\code
48class MySlicer : public Pala::Slicer { ... };
49
50#include <KPluginFactory>
51#include <KPluginLoader>
52
53K_PLUGIN_FACTORY(MySlicerFactory, registerPlugin<MySlicer>();)
54K_EXPORT_PLUGIN(MySlicerFactory("myslicer"))
55\endcode
56 * In the last line, put inside the string literal the file name of the plugin library (e.g. \a myslicer is the name for a library \a libmyslicer.so on unixoid systems, or \a myslicer.dll on Windows systems).
57 */
58 class LIBPALA_EXPORT Slicer : public QObject
59 {
60 Q_OBJECT
61 public:
62 /**
63 * \brief Behavioral flags of a slicer.
64 * These flags can be used to programmatically configure the behavior of libpala for a single slicer. You should only set the slicer's flags once in the constructor, and not modify it later. (The latter might cause unexpected behavior.)
65 * \see setFlags
66 */
67 enum SlicerFlag
68 {
69 NoFlags = 0x0,
70 AllowFullTransparency = 0x1 ///< By default, libpala will increase the minimum alpha value of input images to avoid invisible pieces. Set this flag if you rely on the alpha channel in your slicing algorithm.
71 };
72 Q_DECLARE_FLAGS(SlicerFlags, SlicerFlag)
73
74 /**
75 * \brief Constructs a new Slicer object.
76 * In any subclass, the constructor signature has to be the same (due to the way the plugin loader works). The arguments should be passed to this constructor and ignored by the subclass implementation, as their format might change without notice in future versions.
77 */
78 explicit Slicer(QObject* parent = 0, const QVariantList& args = QVariantList());
79 ///Deletes this slicer, and all properties and modes which have been added with addProperty() and addMode().
80 virtual ~Slicer();
81
82 //The following function belongs to the interface to the Palapeli application. It is not documented because the documentation is targeted at slicer developers.
83 ///\internal
84 ///\since libpala 1.2 (KDE SC 4.6)
85 QList<const Pala::SlicerMode*> modes() const;
86 ///\internal
87 ///\deprecated because sorting order is not right
88 QMap<QByteArray, const Pala::SlicerProperty*> properties() const;
89 ///\internal
90 ///\since libpala 1.2 (KDE SC 4.6)
91 QList<const Pala::SlicerProperty*> propertyList() const; //BIC: rename to properties()
92 ///\internal
93 SlicerFlags flags() const;
94 ///\internal
95 bool process(Pala::SlicerJob* job); //a wrapper function for Pala::Slicer::run
96 //BIC: constify method
97
98 //This class is the only interface that slicers can use to communicate with Palapeli, and it is only instantiated very few times (one instance per slicer plugin), so it should be reasonable to reserve some space in the virtual table for future additions.
99 RESERVE_VIRTUAL_5
100 protected:
101 ///Add the given property to the property list of this slicer. The slicer will take care of destructing the given Pala::SlicerProperty instance when it is destructed.
102 ///Use this method in the subclass constructors to fill the slicer with properties. Properties let the user control how the slicing is done.
103 ///\warning It is not safe to add new properties outside the constructor of a Pala::Slicer subclass.
104 void addProperty(const QByteArray& key, Pala::SlicerProperty* property);
105 //BIC: make interface similar to setMode()
106 ///Add an operation mode to this slicer. The slicer will take care of destructing the given Pala::SlicerMode instance when it is destructed.
107 ///You may use modes e.g. if your slicer includes different slicing algorithms at once which might need a different set of properties (see Pala::SlicerMode documentation for details). If you choose not to use modes, just ignore this function and all other functions concerning modes.
108 ///\warning It is not safe to add new modes outside the constructor of a Pala::Slicer subclass.
109 ///\since libpala 1.2 (KDE SC 4.6)
110 void addMode(Pala::SlicerMode* mode);
111
112 friend class SlicerPropertySet;
113 ///\see Pala::Slicer::SlicerFlags
114 void setFlags(SlicerFlags flags);
115
116 /**
117 * \brief The slicing algorithm.
118 * Implement the slicing algorithm in this method. The slicing algorithm should always respect the current values of the slicer's properties, as defined through the addProperty() method.
119 * \returns whether the operation has been completed successfully
120 * \see Pala::SlicerJob
121 */
122 virtual bool run(Pala::SlicerJob* job) = 0;
123 //BIC: constify method
124 private:
125 class Private;
126 Private* const p;
127 };
128}
129
130Q_DECLARE_OPERATORS_FOR_FLAGS(Pala::Slicer::SlicerFlags)
131
132#endif // LIBPALA_SLICER_H
133

Warning: That file was not part of the compilation database. It may have many parsing errors.