ChunkStream add(int, Chunk)
Graphic save() and load() version 2 git-svn-id: svn://db.shs.com.ru/libs@346 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -1510,25 +1510,67 @@ bool Graphic::legendVisible() const {
|
||||
|
||||
|
||||
QByteArray Graphic::save() {
|
||||
QByteArray ba;
|
||||
QDataStream s(&ba, QIODevice::ReadWrite);
|
||||
s << openGL() << antialiasing() << borderInputsVisible() << statusVisible() << legendVisible();
|
||||
s << graphics;
|
||||
return ba;
|
||||
// QByteArray ba;
|
||||
// QDataStream s(&ba, QIODevice::ReadWrite);
|
||||
// s << openGL() << antialiasing() << borderInputsVisible() << statusVisible() << legendVisible();
|
||||
// s << graphics;
|
||||
// return ba;
|
||||
|
||||
// version '2':
|
||||
ChunkStream cs;
|
||||
cs.add(1, antialiasing()).add(2, openGL()).add(3, borderInputsVisible()).add(4, statusVisible()).add(5, legendVisible());
|
||||
cs.add(6, backgroundColor()).add(7, textColor()).add(8, margins());
|
||||
cs.add(9, gridPen()).add(10, graduationX()).add(11, graduationY()).add(12, graduationStepX()).add(13, graduationStepY());
|
||||
cs.add(14, graphics);
|
||||
cs.add(15, isFit).add(16, visualRect());
|
||||
return cs.data().prepend('2');
|
||||
}
|
||||
|
||||
|
||||
void Graphic::load(QByteArray ba) {
|
||||
if (ba.isEmpty()) return;
|
||||
QDataStream s(ba);
|
||||
bool a;
|
||||
s >> a; setOpenGL(a);
|
||||
s >> a; setAntialiasing(a);
|
||||
s >> a; setBorderInputsVisible(a);
|
||||
s >> a; setStatusVisible(a);
|
||||
s >> a;
|
||||
s >> graphics;
|
||||
setLegendVisible(a);
|
||||
char ver = ba[0];
|
||||
qDebug() << "load" << (int)ver;
|
||||
switch(ver) {
|
||||
case '2': {// version '2':
|
||||
ba.remove(0, 1);
|
||||
QRectF vrect;
|
||||
ChunkStream cs(ba);
|
||||
while (!cs.atEnd()) {
|
||||
switch (cs.read()) {
|
||||
case 1: setAntialiasing(cs.getData<bool>()); break;
|
||||
case 2: setOpenGL(cs.getData<bool>()); break;
|
||||
case 3: setBorderInputsVisible(cs.getData<bool>()); break;
|
||||
case 4: setStatusVisible(cs.getData<bool>()); break;
|
||||
case 5: setLegendVisible(cs.getData<bool>()); break;
|
||||
case 6: setBackgroundColor(cs.getData<QColor>()); break;
|
||||
case 7: setTextColor(cs.getData<QColor>()); break;
|
||||
case 8: setMargins(cs.getData<QRect>()); break;
|
||||
case 9: setGridPen(cs.getData<QPen>()); break;
|
||||
case 10: setGraduationX(cs.getData<Graduation>()); break;
|
||||
case 11: setGraduationY(cs.getData<Graduation>()); break;
|
||||
case 12: setGraduationStepX(cs.getData<double>()); break;
|
||||
case 13: setGraduationStepY(cs.getData<double>()); break;
|
||||
case 14: graphics = cs.getData<QVector<GraphicType> >(); break;
|
||||
case 15: isFit = cs.getData<bool>(); break;
|
||||
case 16: vrect = cs.getData<QRectF>(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (!isFit) setVisualRect(vrect);
|
||||
} break;
|
||||
default: {// old version 0:
|
||||
QDataStream s(ba);
|
||||
bool a;
|
||||
s >> a; setOpenGL(a);
|
||||
s >> a; setAntialiasing(a);
|
||||
s >> a; setBorderInputsVisible(a);
|
||||
s >> a; setStatusVisible(a);
|
||||
s >> a;
|
||||
s >> graphics;
|
||||
setLegendVisible(a);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user