File indexing completed on 2024-05-05 04:05:48
0001 /* 0002 SPDX-FileCopyrightText: 2009 Stefan Majewsky <majewsky@gmx.net> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef LIBPALA_SLICERPROPERTYSET_H 0008 #define LIBPALA_SLICERPROPERTYSET_H 0009 0010 #include "libpala_export.h" 0011 0012 #include <QSize> 0013 0014 #include <memory> 0015 0016 class QByteArray; 0017 0018 namespace Pala 0019 { 0020 class Slicer; 0021 class SlicerJob; 0022 class SlicerProperty; 0023 0024 class SlicerPropertySetPrivate; 0025 0026 /** 0027 * \class SlicerPropertySet slicerpropertyset.h <Pala/SlicerPropertySet> 0028 * \brief Representation of a set of configurable parameters of a slicing algorithm. 0029 * 0030 * In many slicers, you can find common patterns of configuration parameters. For example, many slicers divide the image into X times Y pieces, where X is some configurable "piece count in horizontal direction", and Y is some configurable "piece count in vertical direction". 0031 * 0032 * Such common property sets can be represented by a Pala::SlicerPropertySet subclass. For example, you can add the Pala::SimpleGridPropertySet to your Pala::Slicer subclass to get a set of properties that is useful for slicers that follow the "X times Y pieces" pattern. The recommended way to use property sets is to derive your Pala::Slicer subclass from them (using multiple inheritance; you can safely mix multiple Pala::SlicerPropertySet subclasses into one Pala::Slicer subclass). 0033 * 0034 * A property set is fully self-contained: It adds some properties to your slicer which remain totally invisible to your own implementation. You should always use the methods provided by the property set to read its properties, because the internal representation of the property set might change over time (esp. for those property sets that come with libpala). 0035 * 0036 * \note This is an abstract base class. Use the subclasses provided by this library. Defining own subclasses outside libpala is a good idea if you want to logically separate the configurable parameters of your slicer from the slicing algorithm itself. 0037 */ 0038 class LIBPALA_EXPORT SlicerPropertySet 0039 { 0040 public: 0041 Pala::Slicer* slicer() const; 0042 protected: 0043 SlicerPropertySet(Pala::Slicer* slicer); 0044 SlicerPropertySet(Pala::SlicerPropertySetPrivate& dd); 0045 ~SlicerPropertySet(); 0046 ///A synonym for Pala::Slicer::addProperty (because the latter is "protected"; this abstract base class can access it because it is a "protected friend" of Pala::Slicer). 0047 void addPropertyToSlicer(const QByteArray& key, Pala::SlicerProperty* property); 0048 protected: 0049 std::unique_ptr<class SlicerPropertySetPrivate> const d_ptr; 0050 private: 0051 Q_DECLARE_PRIVATE(SlicerPropertySet) 0052 Q_DISABLE_COPY(SlicerPropertySet) 0053 }; 0054 0055 class SimpleGridPropertySetPrivate; 0056 0057 /** 0058 * \class SimpleGridPropertySet slicerpropertyset.h <Pala/SlicerPropertySet> 0059 * 0060 * This property set can be used for slicers that create pieces which are aligned on a rectangular grid. The property set gives a piece count in horizontal direction, and one in vertical direction. The total piece count is the product of both one-dimensional piece counts. 0061 * 0062 * \note The user interface of this property set does not use the one-dimensional piece counts. It asks for a total piece count and an aspect (which can be anything from tall to square to wide), and calculates the one-dimensional piece counts from this input. 0063 */ 0064 class LIBPALA_EXPORT SimpleGridPropertySet : public Pala::SlicerPropertySet 0065 { 0066 public: 0067 explicit SimpleGridPropertySet(Pala::Slicer* slicer); 0068 ~SimpleGridPropertySet(); 0069 0070 QSize pieceCount(Pala::SlicerJob* job) const; 0071 private: 0072 Q_DECLARE_PRIVATE(SimpleGridPropertySet) 0073 }; 0074 } 0075 0076 #endif // LIBPALA_SLICERPROPERTYSET_H