00001 #ifndef ROOT_HEADER_
00002 #define ROOT_HEADER_
00003
00004 #include "../headers.h"
00005
00006 #include <QThread>
00007
00009
00013 class MRoot: public IRoot {
00014 DECLARE_debugModule;
00015
00016 DECLARE_TypeInfo( MRoot, "Root"
00017 , "Standard root module"
00018 , {
00019 label: "Maximal number of threads",
00020 desc: "Note: the actual number of threads is bound by\n"
00021 "(the number of parts)*(the number of color planes)",
00022 type: settingInt(1,QThread::idealThreadCount(),16)
00023 }, {
00024 label: "Color transformer",
00025 desc: "The module that will be used to transform colors",
00026 type: settingModule<IColorTransformer>()
00027 }, {
00028 label: "Pixel-shape transformer",
00029 desc: "The module that is responsible for shape-transformation\n"
00030 "of the pixels and for further (de)compression",
00031 type: settingModule<IShapeTransformer>()
00032 }, {
00033 label: "Encoding quality (%)",
00034 desc: "Quality - how much accurate the mappings have to be",
00035 type: settingInt(0,90,100)
00036 }, {
00037 label: "Quality converter",
00038 desc: "For given quality and size computes maximum square error allowed",
00039 type: settingModule<IQuality2SE>()
00040 }, {
00041 label: "Maximum domain count",
00042 desc: "Maximum domain count for level 2 range blocks\n"
00043 "(for this purpose are different rotations\n"
00044 "of one domain counted as different domains)",
00045 type: settingInt(0,19,30,IntLog2)
00046 } )
00047
00048 protected:
00050 enum Settings { MaxThreads, ModuleColor, ModuleShape, Quality, ModuleQuality
00051 , DomainCountLog2 };
00052
00053 int maxThreads() const
00054 { return settingsInt(MaxThreads); }
00055 IColorTransformer* moduleColor() const
00056 { return debugCast<IColorTransformer*>(settings[ModuleColor].m); }
00057 IShapeTransformer* moduleShape() const
00058 { return debugCast<IShapeTransformer*>(settings[ModuleShape].m); }
00059 float quality()
00060 { return settingsInt(Quality)/100.0; }
00061 IQuality2SE* moduleQuality() const
00062 { return debugCast<IQuality2SE*>(settings[ModuleQuality].m); }
00063
00064 typedef IColorTransformer::PlaneSettings PlaneSettings;
00065 typedef IColorTransformer::PlaneList PlaneList;
00066
00067 protected:
00068
00069 Mode myMode;
00070 int width
00071 , height
00072 , zoom;
00073
00074 protected:
00075
00076 MRoot(): myMode(Clear), width(0), height(0), zoom(-1) {}
00077
00078 public:
00081 Mode getMode() { return myMode; }
00082 QImage toImage();
00083
00084 bool encode(const QImage &toEncode,const UpdateInfo &updateInfo);
00085 void decodeAct(DecodeAct action,int count=1);
00086
00087 bool toStream(std::ostream &file);
00088 bool fromStream(std::istream &file,int zoom);
00090 };
00091
00092 #endif // ROOT_HEADER_