File indexing completed on 2024-05-12 04:05:54

0001 /***************************************************************************
0002  *   Copyright 2005-2007 Francesco Rossi <redsh@email.it>                  *
0003  *   Copyright 2006-2007 Mick Kappenburg <ksudoku@kappendburg.net>         *
0004  *   Copyright 2006-2008 Johannes Bergmeier <johannes.bergmeier@gmx.net>   *
0005  *   Copyright 2012      Ian Wadham <iandw.au@gmail.com>                   *
0006  *                                                                         *
0007  *   This program is free software; you can redistribute it and/or modify  *
0008  *   it under the terms of the GNU General Public License as published by  *
0009  *   the Free Software Foundation; either version 2 of the License, or     *
0010  *   (at your option) any later version.                                   *
0011  *                                                                         *
0012  *   This program is distributed in the hope that it will be useful,       *
0013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0015  *   GNU General Public License for more details.                          *
0016  *                                                                         *
0017  *   You should have received a copy of the GNU General Public License     *
0018  *   along with this program; if not, write to the                         *
0019  *   Free Software Foundation, Inc.,                                       *
0020  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0021  ***************************************************************************/
0022 
0023 #ifndef ROXDOKUVIEW_h
0024 #define ROXDOKUVIEW_h
0025 
0026 #include <QOpenGLWidget>
0027 #include <QMouseEvent>
0028 #include <QTimer>
0029 #include <QWheelEvent>
0030 
0031 #include "ArcBall.h"
0032 
0033 #include "ksudokugame.h"
0034 #include "ksview.h"
0035 
0036 class SKGraph;
0037 
0038 namespace ksudoku{
0039 
0040 class Game;
0041 class GameActions;
0042 
0043 /**
0044  * GUI for a Roxdoku puzzle.
0045  */
0046 class RoxdokuView : public QOpenGLWidget, public ViewInterface
0047 {
0048 Q_OBJECT
0049 public:
0050     RoxdokuView(const ksudoku::Game &game, GameActions * gameActions, QWidget * parent = nullptr);
0051     ~RoxdokuView() override;
0052 
0053     virtual QString status() const;
0054 
0055     void initializeGL() override;
0056 
0057     void resizeGL(int w, int h ) override;
0058 
0059     QWidget* widget() override { return this; }
0060 
0061 public Q_SLOTS:
0062     void selectValue(int value) override;
0063     void settingsChanged();
0064     void enterValue(int value);
0065 
0066 Q_SIGNALS:
0067     void valueSelected(int value); // Never used but connected to
0068 
0069 protected:
0070     void paintGL() override;
0071 
0072     void myDrawCube(bool highlight, int cell,
0073             GLfloat x, GLfloat y, GLfloat z,
0074             bool outside);
0075 
0076     void Selection(int mouse_x, int mouse_y);
0077     void mouseReleaseEvent ( QMouseEvent * e )override {
0078         if(e->button() == Qt::LeftButton) m_isClicked = false;
0079     }
0080     void mousePressEvent ( QMouseEvent * e )override {
0081         if(e->button() == Qt::LeftButton) m_isClicked = true;
0082     }   
0083     void mouseMoveEvent(QMouseEvent* e)  override;
0084     void mouseDoubleClickEvent(QMouseEvent* e) override;
0085     void wheelEvent (QWheelEvent* e)override {
0086             m_wheelmove += e->angleDelta().y() * .02;
0087         update();
0088     }
0089 
0090 private Q_SLOTS:
0091     void delayOver();
0092 
0093 private:
0094     void loadSettings();
0095 
0096     Game         m_game;
0097     SKGraph *    m_graph;
0098 
0099     int          m_base;
0100     int          m_order;
0101     int          m_size;
0102     int          m_width;
0103     int          m_height;
0104     int          m_depth;
0105 
0106     char         m_selected_number;
0107 
0108     ArcBallT *   m_arcBall; 
0109     bool         m_isClicked;
0110     bool         m_isRClicked;  
0111     bool         m_isDragging;  
0112     int          m_selection;
0113     int          m_lastSelection;
0114     QList<int>   m_highlights;
0115 
0116     float        m_dist;
0117     float        m_wheelmove;
0118 
0119     GLuint       m_texture[2][26];
0120 
0121     bool         m_guidedMode;
0122     bool         m_showHighlights;
0123     float        m_selectionSize;
0124     float        m_highlightedSize;
0125     float        m_unhighlightedSize;
0126     float        m_outerCellSize;
0127     bool         m_darkenOuterCells;
0128 
0129     QTimer *     m_delayTimer;
0130     bool         m_timeDelay;
0131 };
0132 
0133 }
0134 
0135 #endif