2010-06-16 12:53:56 +00:00
|
|
|
/***************************************************************************
|
2011-12-21 11:49:33 +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;
|
|
|
|
|
2011-12-21 11:49:33 +00:00
|
|
|
namespace libqnono {
|
2010-06-16 12:53:56 +00:00
|
|
|
class CNonogram {
|
|
|
|
public:
|
|
|
|
typedef QVector<quint16> NumbersVector;
|
|
|
|
|
|
|
|
CNonogram();
|
|
|
|
CNonogram(QSize size);
|
2011-12-21 11:49:33 +00:00
|
|
|
CNonogram(QImage & image);
|
|
|
|
CNonogram(QDataStream & stream);
|
2010-06-16 12:53:56 +00:00
|
|
|
~CNonogram();
|
|
|
|
|
|
|
|
void loadFromImage(QImage & image);
|
|
|
|
void resize(QSize size);
|
|
|
|
|
2012-02-28 10:33:20 +00:00
|
|
|
bool readFromStream(QDataStream & stream);
|
|
|
|
void writeToStream(QDataStream & stream);
|
|
|
|
|
2011-12-21 11:49:33 +00:00
|
|
|
inline QString name() const { return m_Name; }
|
|
|
|
inline void setName(QString value) { m_Name = value; }
|
2010-06-16 12:53:56 +00:00
|
|
|
|
2011-12-21 11:49:33 +00:00
|
|
|
inline quint16 timeout() const { return m_Timeout; }
|
2010-06-16 12:53:56 +00:00
|
|
|
void setTimeout(quint16 value) { m_Timeout = value; }
|
|
|
|
|
2011-12-21 11:49:33 +00:00
|
|
|
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
|
|
|
|
2011-12-21 11:49:33 +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]; }
|
|
|
|
|
2011-12-21 11:49:33 +00:00
|
|
|
inline int maximumNumberCount() const { return m_MaximumNumberCount; }
|
2010-06-16 12:53:56 +00:00
|
|
|
|
2011-12-21 11:49:33 +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();
|
|
|
|
};
|
2011-12-21 11:49:33 +00:00
|
|
|
|
|
|
|
QDataStream & operator<<(QDataStream & stream, CNonogram & nonogram);
|
|
|
|
QDataStream & operator>>(QDataStream & stream, CNonogram & nonogram);
|
2010-06-16 12:53:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|