Reimplemented things working with summed pixels, other fixes.
[fic.git] / modules / root.h
blobad4397b55d8e9d83fcc3c289082712921e18af9b
1 #ifndef ROOT_HEADER_
2 #define ROOT_HEADER_
4 #include "../interfaces.h"
6 //#include <QThread>
8 /** The root module */
9 class MRoot: public IRoot {
10 DECLARE_debugModule;
12 DECLARE_TypeInfo( MRoot, "Root"
13 , "Standard root module"
14 , {
15 label: "Maximal number of threads",
16 desc: "Note: the actual number of threads is bound by\n"
17 "(the number of parts)*(the number of color planes)",
18 type: settingInt(1,1,1) // abs(QThread::idealThreadCount())
19 }, {
20 label: "Color transformer",
21 desc: "The module that will be used to transform colors",
22 type: settingModule<IColorTransformer>()
23 }, {
24 label: "Pixel-shape transformer",
25 desc: "The module that is responsible for shape-transformation\n"
26 "of the pixels and for further (de)compression",
27 type: settingModule<IShapeTransformer>()
28 }, {
29 label: "Encoding quality",
30 desc: "Quality - how much accurate the mappings have to be",
31 type: settingInt(0,90,100)
32 }, {
33 label: "Quality converter",
34 desc: "For given quality and size computes maximum square error allowed",
35 type: settingModule<IQuality2SquareError>()
36 }, {
37 label: "Maximum domain count",
38 desc: "Maximum domain count for level 2 range blocks\n"
39 "(for this purpose are different rotations\n"
40 "of one domain counted as different domains)",
41 type: settingInt(0,15,24,IntLog2)
42 } )
44 private:
45 /** Indices for settings */
46 enum Settings { MaxThreads, ModuleColor, ModuleShape, Quality, ModuleQuality
47 , DomainCountLog2 };
48 // Settings-retrieval methods
49 int maxThreads() const
50 { return settingsInt(MaxThreads); }
51 IColorTransformer* moduleColor() const
52 { return debugCast<IColorTransformer*>(settings[ModuleColor].m); }
53 IShapeTransformer* moduleShape() const
54 { return debugCast<IShapeTransformer*>(settings[ModuleShape].m); }
55 float quality()
56 { return settingsInt(Quality)/100.0; }
57 IQuality2SquareError* moduleQuality() const
58 { return debugCast<IQuality2SquareError*>(settings[ModuleQuality].m); }
60 typedef IColorTransformer::PlaneSettings PlaneSettings;
61 typedef IColorTransformer::PlaneList PlaneList;
63 private:
64 // Module's data
65 Mode myMode;
66 int width, height, zoom;
68 protected:
69 // Construction and destruction
70 MRoot(): myMode(Clear), width(0), height(0), zoom(-1) {}
72 public:
73 /** \name IRoot interface
74 * @{ */
75 Mode getMode() { return myMode; }
76 QImage toImage();
78 bool encode(const QImage &toEncode,const UpdateInfo &updateInfo);
79 void decodeAct(DecodeAct action,int count=1);
81 bool toStream(std::ostream &file);
82 bool fromStream(std::istream &file,int zoom);
83 /// @}
86 #endif // ROOT_HEADER_