File indexing completed on 2024-05-05 04:05:48
0001 /* 0002 SPDX-FileCopyrightText: 2010 Stefan Majewsky <majewsky@gmx.net> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef LIBPALA_SLICERMODE_H 0008 #define LIBPALA_SLICERMODE_H 0009 0010 #include "libpala_export.h" 0011 0012 #include <QByteArray> 0013 0014 #include <memory> 0015 0016 namespace Pala 0017 { 0018 class SlicerProperty; 0019 0020 /** 0021 * \class SlicerMode slicermode.h <Pala/SlicerMode> 0022 * \brief Representation of an operational mode of a slicing algorithm. 0023 * \since libpala 1.2 (KDE SC 4.6) 0024 * 0025 * Complex slicer plugins may include several slicing algorithms at once. This class represents such operational modes. Basically, the usage of slicer modes is identical to creating a Pala::StringProperty with a finite set of choices, but slicer modes have some advantages: 0026 * \li You can choose to enable or disable properties depending on the selected slicer mode. 0027 * \li You can create an own SlicerMode subclass and aggregate in it algorithms that are relevant to this mode. 0028 * You are free not to use slicer modes: Just disregard this class and all functions in other classes that deal with slicer modes. 0029 * 0030 * \sa Pala::Slicer::addMode, Pala::SlicerJob::mode 0031 */ 0032 class LIBPALA_EXPORT SlicerMode 0033 { 0034 public: 0035 ///Create a new SlicerMode instance. 0036 ///\param key an identifier which is unique among the modes of one slicer 0037 ///\param name a user-visible name that describes this mode 0038 SlicerMode(const QByteArray& key, const QString& name); 0039 virtual ~SlicerMode(); 0040 0041 //The following functions belong to the interface to the Palapeli application. They are not documented because the documentation is targeted at slicer developers. 0042 ///\internal 0043 void filterProperties(QList<const Pala::SlicerProperty*>& properties) const; //This function removes all properties from the given map which are disabled in this mode, taking both Pala::SlicerProperty::isEnabled and the exceptions defined by this mode into account. 0044 ///\internal 0045 QByteArray key() const; 0046 ///\internal 0047 QString name() const; 0048 0049 ///Defines whether the property which has been added to Pala::Slicer with the given key, is enabled when this mode is selected. If this mode does not define the state for some property, the state defined by the property itself (through the Palapeli::SlicerProperty::setEnabled() method) is used. You will therefore probably use this function only to define exceptions from this default state. 0050 void setPropertyEnabled(const QByteArray& property, bool enabled); 0051 0052 //Some space in the vtable reserved for future additions 0053 //RESERVE_VIRTUAL_5 0054 private: 0055 std::unique_ptr<class SlicerModePrivate> const d_ptr; 0056 Q_DECLARE_PRIVATE(SlicerMode) 0057 Q_DISABLE_COPY(SlicerMode) 0058 // TODO: consider turning this into a value-type class with shared data 0059 }; 0060 } 0061 0062 #endif // LIBPALA_SLICERMODE_H