4 #include "../interfaces.h"
6 #include <QThread> // ::idealThreadCount
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
{
16 DECLARE_TypeInfo( MRoot
, "Root"
17 , "Standard root module"
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)
24 label
: "Color transformer",
25 desc
: "The module that will be used to transform colors",
26 type
: settingModule
<IColorTransformer
>()
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
>()
33 label
: "Encoding quality (%)",
34 desc
: "Quality - how much accurate the mappings have to be",
35 type
: settingInt(0,90,100)
37 label
: "Quality converter",
38 desc
: "For given quality and size computes maximum square error allowed",
39 type
: settingModule
<IQuality2SE
>()
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,15,24,IntLog2
)
49 /** Indices for settings */
50 enum Settings
{ MaxThreads
, ModuleColor
, ModuleShape
, Quality
, ModuleQuality
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
); }
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
;
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)
75 // Construction and destruction
76 MRoot(): myMode(Clear
), width(0), height(0), zoom(-1) {}
79 /** \name IRoot interface
81 Mode
getMode() { return myMode
; }
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
);
92 #endif // ROOT_HEADER_