Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
PaletteServer.h
Go to the documentation of this file.
1#pragma once
2#include <QPainter>
6
7namespace sf
8{
9
13class _PAL_CLASS PaletteServer : public QObject
14{
15 Q_OBJECT
16
17 public:
21 explicit PaletteServer(QObject* parent = nullptr);
22
26 ~PaletteServer() override;
27
32
36 [[nodiscard]] ColorTable getColorTable() const;
37
43 void setColorCount(int colorsUsed, int colorsSize = -1);
44
48 void paint(QPainter& painter, const QRect& bounds) const;
49
53 [[nodiscard]] QList<QPair<QString, QString>> getImplementationNames() const;
54
58 [[nodiscard]] const QString& getImplementationName() const;
59
63 [[nodiscard]] bool isAvailable() const;
64
68 void setImplementationName(const QString& name);
72 [[nodiscard]] const QStringList& getImplementationProperties();
73
77 void setImplementationProperties(const QStringList& props);
78
82 // ReSharper disable once CppFunctionIsNotImplemented
83 Q_SIGNAL void changed(PaletteServer* sender);
84
85 protected:
90 bool createImplementation(const std::string& name);
91
92 private:
93 // Gets the registered name of the current implementation.
94 [[nodiscard]] std::string currentImplementationName() const;
95 // Holds the desired name of the implementation.
96 QString _implementationName;
97 // Holds the implementation of the palette.
98 PaletteInterface* _implementation;
99 QStringList _implementationProperties;
100 // Holds the size of the colors needed.
101 int _colorsSize;
102 // Holds the amount of colors used for the calculating the scale.
103 int _colorsUsed;
104 // Local fast copy of the generated table.
105 ColorTable _colorTable;
106 // Holds the flag to generate the color table.
107 bool _flagGenerate;
108
110};
111
112}// namespace sf
Base class for the interface.
Definition PaletteInterface.h:20
Definition PaletteServerPropertyPage.h:16
Server for color palettes used in images for coloring on basis of index.
Definition PaletteServer.h:14
void setImplementationProperties(const QStringList &props)
Sets the name of the desired implementation.
QList< QPair< QString, QString > > getImplementationNames() const
Gets the names of all available implementations names and descriptions in pairs.
ColorTable getColorTable() const
Gets the generated color table of the selected.
void addPropertyPages(PropertySheetDialog *sheet)
Adds property pages of the select palette.
void setColorCount(int colorsUsed, int colorsSize=-1)
void paint(QPainter &painter, const QRect &bounds) const
Paints the palette using the passed painter instance.
const QStringList & getImplementationProperties()
Gets the name of the desired implementation.
bool createImplementation(const std::string &name)
Creates implementation by registered name.
Q_SIGNAL void changed(PaletteServer *sender)
Signal for when the palette changes.
const QString & getImplementationName() const
Gets the name of the desired implementation.
~PaletteServer() override
Destructor.
bool isAvailable() const
Returns true when an implementation is available.
void setImplementationName(const QString &name)
Sets the name of the desired implementation.
PaletteServer(QObject *parent=nullptr)
Constructor.
Dialog containing multiple property pages.
Definition qt/PropertySheetDialog.h:14
Definition Application.h:10
QList< QRgb > ColorTable
Definition ColorTable.h:11
#define _PAL_CLASS
Definition pal/iface/global.h:35