Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef MWAW_PICT
00043 # define MWAW_PICT
00044
00045 # include <assert.h>
00046 # include <ostream>
00047 # include <vector>
00048
00049 # include "libmwaw_internal.hxx"
00050
00052 class MWAWPict
00053 {
00054 public:
00056 virtual ~MWAWPict() {}
00057
00064 enum Type { PictData, Bitmap, Unknown };
00066 virtual Type getType() const = 0;
00067
00074 enum ReadResult { MWAW_R_BAD=0, MWAW_R_OK, MWAW_R_OK_EMPTY, MWAW_R_MAYBE };
00075
00077 MWAWBox2f getBdBox() const
00078 {
00079 MWAWBox2f res(m_bdbox);
00080 res.extend(m_bdBoxExt);
00081 return res;
00082 }
00083
00085 void setBdBox(MWAWBox2f const &box)
00086 {
00087 m_bdbox = box;
00088 }
00089
00094 virtual bool getBinary(librevenge::RVNGBinaryData &, std::string &) const
00095 {
00096 return false;
00097 }
00098
00102 virtual int cmp(MWAWPict const &a) const
00103 {
00104
00105 int diff = m_bdbox.cmp(a.m_bdbox);
00106 if (diff) return diff;
00107
00108 diff = getType() - a.getType();
00109 if (diff) return (diff < 0) ? -1 : 1;
00110
00111 return 0;
00112 }
00113 protected:
00115 static MWAWBox2f getBdBox(int numPt, MWAWVec2f const *pt)
00116 {
00117 if (numPt <= 0) {
00118 return MWAWBox2f();
00119 }
00120
00121 float minV[2], maxV[2];
00122 for (int c = 0; c < 2; c++) minV[c] = maxV[c] = pt[0][c];
00123
00124 for (int i = 1; i < numPt; i++) {
00125 for (int c = 0; c < 2; c++) {
00126 float v = pt[i][c];
00127 if (v < minV[c]) minV[c] = v;
00128 else if (v > maxV[c]) maxV[c] = v;
00129 }
00130 }
00131
00132 return MWAWBox2f(MWAWVec2f(minV[0], minV[1]), MWAWVec2f(maxV[0], maxV[1]));
00133 }
00134
00135
00136
00138 void extendBDBox(float val)
00139 {
00140 m_bdBoxExt = val;
00141 }
00142
00144 MWAWPict() : m_bdbox(), m_bdBoxExt(0.0) {}
00146 MWAWPict(MWAWPict const &p) : m_bdbox(), m_bdBoxExt(0.0)
00147 {
00148 *this=p;
00149 }
00151 MWAWPict &operator=(MWAWPict const &p)
00152 {
00153 if (&p == this) return *this;
00154 m_bdbox = p.m_bdbox;
00155 m_bdBoxExt = p.m_bdBoxExt;
00156 return *this;
00157 }
00158
00159 private:
00161 MWAWBox2f m_bdbox;
00163 float m_bdBoxExt;
00164 };
00165
00166 #endif
00167