File indexing completed on 2024-05-19 04:36:39

0001 /* This file is part of the TikZKit project.
0002  *
0003  * Copyright (C) 2013-2014 Dominik Haumann <dhaumann@kde.org>
0004  *
0005  * This library is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU Library General Public License as published
0007  * by the Free Software Foundation, either version 2 of the License, or
0008  * (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  * GNU Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, see
0017  * <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #ifndef TIKZ_UI_VIEW_PRIVATE_H
0021 #define TIKZ_UI_VIEW_PRIVATE_H
0022 
0023 #include "tikzui_export.h"
0024 #include "View.h"
0025 
0026 #include <tikz/core/Value.h>
0027 #include <tikz/core/Pos.h>
0028 
0029 namespace tikz {
0030 namespace ui {
0031 
0032 class DocumentPrivate;
0033 class Renderer;
0034 
0035 class ViewPrivate : public tikz::ui::View
0036 {
0037     Q_OBJECT
0038 
0039     public:
0040         /**
0041          * Constructor.
0042          */
0043         ViewPrivate(tikz::ui::DocumentPrivate * doc,
0044                     QWidget * parent = nullptr,
0045                     tikz::ui::MainWindow * mainWindow = nullptr);
0046 
0047         /**
0048          * Destructor.
0049          */
0050         virtual ~ViewPrivate();
0051 
0052     //
0053     // General Document and MainWindow properties
0054     //
0055     public:
0056         /**
0057          * Returns the associated tikz Document.
0058          */
0059         tikz::ui::Document * document() const override;
0060 
0061         /**
0062          * Get the view's main window, if any
0063          * \return the view's main window
0064          */
0065         tikz::ui::MainWindow * mainWindow() const override;
0066 
0067         /**
0068          * Returns this View's ZoomController object.
0069          */
0070         tikz::ui::ZoomController * zoomController() const override;
0071 
0072         /**
0073          * Returns the edit mode.
0074          */
0075         TikzEditMode editMode() const override;
0076 
0077         /**
0078          * Set the edit mode.
0079          */
0080         void setEditMode(TikzEditMode mode) const override;
0081 
0082         /**
0083          * Check whether the view has selected items.
0084          */
0085         bool hasSelection() const override;
0086 
0087         /**
0088          * Unselect all selected items (without deleting the selected items).
0089          */
0090         void clearSelection() override;
0091 
0092         /**
0093          * Returns the selected items in the scene.
0094          */
0095         QList<TikzItem *> selectedItems() const override;
0096 
0097     public:
0098         /**
0099          * Snap @p value to the grid.
0100          */
0101         tikz::Value snapValue(const tikz::Value & value) const;
0102 
0103         /**
0104          * Snap x/y components of @p pos to the grid.
0105          */
0106         tikz::Pos snapPos(const tikz::Pos & pos) const;
0107 
0108         /**
0109          * Snap @p angle in degrees to a 15° raster.
0110          */
0111         qreal snapAngle(qreal angle) const;
0112 
0113     public:
0114         /**
0115          * Returns the QGraphicsView that renders the scene.
0116          */
0117         Renderer * renderer() const;
0118 
0119     public Q_SLOTS:
0120         /**
0121          * Relay slot to forward selection changed signal with view parameter.
0122          */
0123         void slotSelectionChanged();
0124 
0125     private:
0126         tikz::ui::DocumentPrivate * m_doc;
0127         tikz::ui::MainWindow * m_mainWindow;
0128         tikz::ui::Renderer * m_renderer;
0129 };
0130 
0131 }
0132 }
0133 
0134 #endif // TIKZ_UI_VIEW_PRIVATE_H
0135 
0136 // kate: indent-width 4; replace-tabs on;