valentina/src/app/puzzle/vptilefactory.h

114 lines
3.2 KiB
C
Raw Normal View History

/************************************************************************
**
** @file vptilefactory.h
** @author Ronan Le Tiec
** @date 19 11, 2020
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2020 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina 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 3 of the License, or
** (at your option) any later version.
**
** Valentina 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 Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPTILEFACTORY_H
#define VPTILEFACTORY_H
#include <QtMath>
#include <QObject>
2021-08-17 17:49:28 +02:00
#include "layout/vplayout.h"
2021-09-06 14:31:19 +02:00
class QGraphicsScene;
2021-08-09 14:09:10 +02:00
class VCommonSettings;
class QPainter;
class VPTileFactory : QObject
{
Q_OBJECT
public:
2021-08-17 17:49:28 +02:00
VPTileFactory(const VPLayoutPtr &layout, VCommonSettings *commonSettings);
2021-08-17 17:49:28 +02:00
virtual ~VPTileFactory() = default;
/**
* @brief drawTile draws the tile of given coordinate (row, col) from the
* current sheet of the layout with the given painter
* @param painter pointer to painter
* @param row current row
* @param col current column
*/
2021-09-06 14:31:19 +02:00
void drawTile(QPainter *painter, QPrinter *printer, const VPSheetPtr &sheet, int row, int col);
/**
2021-09-06 14:31:19 +02:00
* @brief refreshTileInfos Resfreshes the tile infos (m_drawingAreaHeight, m_drawingAreaWidth)
*/
void refreshTileInfos();
/**
2021-09-06 14:31:19 +02:00
* @brief RowNb Returns the number of row pages
* @return number of row pages
*/
2021-09-06 14:31:19 +02:00
auto RowNb(const VPSheetPtr &sheet) const -> int;
/**
2021-09-06 14:31:19 +02:00
* @brief ColNb Returns the number of col pages
* @return number of col pages
*/
2021-09-06 14:31:19 +02:00
auto ColNb(const VPSheetPtr &sheet) const -> int;
/**
2021-09-06 14:31:19 +02:00
* @brief DrawingAreaHeight Returns the usable height of the tile in Px
* @return usable height of the tile in Px
*/
2021-09-06 14:31:19 +02:00
auto DrawingAreaHeight() const -> qreal;
/**
2021-09-06 14:31:19 +02:00
* @brief DrawingAreaWidth Returns the usable width of the tile in Px
* @return usable width of the tile in Px
*/
2021-09-06 14:31:19 +02:00
auto DrawingAreaWidth() const -> qreal;
2021-09-07 19:26:35 +02:00
/**
* @brief tileStripeWidth the width of the info / glueing stripe in Px
*/
static constexpr qreal tileStripeWidth = UnitConvertor(1, Unit::Cm, Unit::Px);
private:
Q_DISABLE_COPY(VPTileFactory)
2021-08-17 17:49:28 +02:00
VPLayoutWeakPtr m_layout;
VCommonSettings *m_commonSettings{nullptr};
/**
* @brief m_drawingAreaHeight the height of the drawing area
*/
qreal m_drawingAreaHeight{0};
/**
* @brief m_drawingAreaWidth the width of the drawing area
*/
qreal m_drawingAreaWidth{0};
2021-09-08 09:41:35 +02:00
void DrawRuler(QPainter *painter);
};
#endif // VPTILEFACTORY_H