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