qcross/libqnono/cnonogram.h

94 lines
3.2 KiB
C++

/***************************************************************************
* Copyright (C) 2008 by Oliver Groß *
* z.o.gross@gmx.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef LIBQCROSS_CMONOPICTURE_H
#define LIBQCROSS_CMONOPICTURE_H
#include <QSize>
#include <QVector>
#include <QString>
class QImage;
namespace libqnono {
class CNonogram {
public:
typedef QVector<quint16> NumbersVector;
CNonogram();
CNonogram(QSize size);
CNonogram(QImage & image);
CNonogram(QDataStream & stream);
~CNonogram();
void loadFromImage(QImage & image);
void resize(QSize size);
bool readFromStream(QDataStream & stream);
void writeToStream(QDataStream & stream);
inline QString name() const { return m_Name; }
inline void setName(QString value) { m_Name = value; }
inline quint16 timeout() const { return m_Timeout; }
void setTimeout(quint16 value) { m_Timeout = value; }
inline QSize size() const { return m_Size; }
inline int width() const { return m_Size.width(); }
inline int height() const { return m_Size.height(); }
inline bool pixel(int x, int y) const { return m_Data[x][y]; }
void setPixel(int x, int y, bool value);
NumbersVector & rowNumbers(int index) const { return m_RowNumbers[index]; }
NumbersVector & columnNumbers(int index) const { return m_ColumnNumbers[index]; }
inline int maximumNumberCount() const { return m_MaximumNumberCount; }
inline quint32 blackPixels() const { return m_BlackPixels; }
void updateNumbers();
void fill(bool value);
bool isValid() const { return m_Data; }
protected:
QSize m_Size;
bool ** m_Data;
QString m_Name;
quint16 m_Timeout;
NumbersVector * m_RowNumbers;
NumbersVector * m_ColumnNumbers;
quint32 m_BlackPixels;
int m_MaximumNumberCount;
void cleanup();
void init();
};
QDataStream & operator<<(QDataStream & stream, CNonogram & nonogram);
QDataStream & operator>>(QDataStream & stream, CNonogram & nonogram);
}
#endif