qcross/libqnono/cnonogram.h

96 lines
3.3 KiB
C
Raw Normal View History

2010-06-16 12:53:56 +00:00
/***************************************************************************
* Copyright (C) 2008 by Oliver Groß *
* z.o.gross@gmx.de *
2010-06-16 12:53:56 +00:00
* *
* 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 {
2010-06-16 12:53:56 +00:00
class CNonogram {
public:
typedef QVector<quint16> NumbersVector;
CNonogram();
CNonogram(QSize size);
CNonogram(QImage & image);
CNonogram(QDataStream & stream);
CNonogram(const CNonogram &other);
2010-06-16 12:53:56 +00:00
~CNonogram();
CNonogram& operator=(const CNonogram &other);
2010-06-16 12:53:56 +00:00
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; }
2010-06-16 12:53:56 +00:00
inline quint16 timeout() const { return m_Timeout; }
2010-06-16 12:53:56 +00:00
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(); }
2010-06-16 12:53:56 +00:00
inline bool pixel(int x, int y) const { return m_Data[x][y]; }
2010-06-16 12:53:56 +00:00
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; }
2010-06-16 12:53:56 +00:00
inline quint32 blackPixels() const { return m_BlackPixels; }
2010-06-16 12:53:56 +00:00
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);
2010-06-16 12:53:56 +00:00
}
#endif