qcross/libqnono/nonogramnumbers.h

66 lines
2.6 KiB
C++

/***************************************************************************
* Copyright (C) 2012 Stefan Bühler <stbuehler@web.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 LIBQNONO_NONOGRAMNUMBERS_H
#define LIBQNONO_NONOGRAMNUMBERS_H
#include <QVector>
#include <QSize>
#include <QImage>
namespace libqnono {
class NonogramImage;
class NonogramNumbers {
public:
typedef QVector<quint16> v_num;
typedef QVector<v_num> vv_num;
NonogramNumbers();
NonogramNumbers(const vv_num & rows, const vv_num & columns);
NonogramNumbers(const NonogramImage & image);
NonogramNumbers(const QImage & image);
void calcFromImage(const NonogramImage & image);
// one pixel changed, only update the row and column for it
void updateFromImage(const NonogramImage & image, int x, int y);
bool readFromStream(QDataStream & stream);
void writeToStream(QDataStream & stream);
bool operator==(const NonogramNumbers &other) const;
const vv_num & rows() const { return m_rows; }
const vv_num & columns() const { return m_columns; }
int maximumNumberCount() const;
QSize size() const { return QSize(m_columns.count(), m_rows.count()); }
int width() const { return m_columns.count(); }
int height() const { return m_rows.count(); }
bool check(const NonogramImage & image) const;
private:
vv_num m_rows, m_columns;
};
}
#endif // LIBQNONO_NONOGRAMNUMBERS_H