File indexing completed on 2025-01-12 05:04:31

0001 /***************************************************************************
0002  *     Copyright (C) 2009 by Renaud Guezennec                             *
0003  *   https://rolisteam.org/contact                   *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify     *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program 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 General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
0019  ***************************************************************************/
0020 #ifndef RGRAPHICSVIEW_H
0021 #define RGRAPHICSVIEW_H
0022 
0023 #include <QGraphicsView>
0024 #include <QPointer>
0025 
0026 #include "commands/changestackordervmapcommand.h"
0027 #include "controller/item_controllers/visualitemcontroller.h"
0028 #include "preferences/preferencesmanager.h"
0029 #include "rwidgets_global.h"
0030 
0031 class VectorialMapController;
0032 
0033 /**
0034  * @brief RGraphicsView is custom graphicsview to fit rolisteam needs. It will implement some important feature
0035  */
0036 class RWIDGET_EXPORT RGraphicsView : public QGraphicsView
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041     /**
0042      * @brief constructor with parameters
0043      * @param Map address which it will be displayed by the graphicsview
0044      */
0045     RGraphicsView(VectorialMapController* ctrl, QWidget* parent= nullptr);
0046 
0047     void currentToolChanged(Core::SelectableTool selectedtool);
0048 
0049     void deleteItem(const QList<vmap::VisualItemController*>& list);
0050     void setItemLayer(const QList<vmap::VisualItemController*>& list, Core::Layer layer);
0051     void setRotation(const QList<vmap::VisualItemController*>& list, int value);
0052 
0053 public slots:
0054     void addImageToMap();
0055     void centerOnItem();
0056 
0057 protected:
0058     void mousePressEvent(QMouseEvent* event);
0059     void wheelEvent(QWheelEvent* event);
0060     void contextMenuEvent(QContextMenuEvent* event);
0061     void resizeEvent(QResizeEvent* event);
0062 
0063     void createAction();
0064     void lockItems(const QList<vmap::VisualItemController*>& list);
0065 
0066     QList<ItemToControllerInfo> selection();
0067 
0068 signals:
0069     void updateVisualZone();
0070 
0071 private slots:
0072     void rollInit();
0073     void cleanInit();
0074     void setZoomFactor();
0075     void changeLayer();
0076     void changeVisibility();
0077     void updateSizeToController();
0078     void stackBefore(const QList<ItemToControllerInfo>& first, const QList<ItemToControllerInfo>& second);
0079 
0080 private:
0081     QPointer<VectorialMapController> m_ctrl;
0082 
0083     int m_counterZoom;
0084 
0085     QAction* m_zoomNormal= nullptr;
0086     QAction* m_zoomInMax= nullptr;
0087     QAction* m_zoomOutMax= nullptr;
0088     QAction* m_zoomIn= nullptr;
0089     QAction* m_zoomOut= nullptr;
0090     QAction* m_zoomCenterOnItem= nullptr;
0091     QAction* m_properties= nullptr;
0092     QAction* m_editGroundLayer= nullptr;
0093     QAction* m_editObjectLayer= nullptr;
0094     QAction* m_editCharacterLayer= nullptr;
0095     QAction* m_editGameMasterLayer= nullptr;
0096 
0097     // Global action
0098     QAction* m_rollInitOnAllNpc= nullptr;
0099     QAction* m_rollInitOnSelection= nullptr;
0100     QAction* m_rollInitOnAllCharacter= nullptr;
0101     QAction* m_cleanInitOnAllNpc= nullptr;
0102     QAction* m_cleanInitOnSelection= nullptr;
0103     QAction* m_cleanInitOnAllCharacter= nullptr;
0104 
0105     QAction* m_normalizeSizeAverage= nullptr;
0106     QAction* m_normalizeSizeUnderMouse= nullptr;
0107     QAction* m_normalizeSizeBigger= nullptr;
0108     QAction* m_normalizeSizeSmaller= nullptr;
0109 
0110     QAction* m_lockSize= nullptr;
0111     QAction* m_dupplicate{nullptr};
0112 
0113     QAction* m_allVisibility= nullptr;
0114     QAction* m_hiddenVisibility= nullptr;
0115     QAction* m_characterVisibility= nullptr;
0116 
0117     QAction* m_putGroundLayer= nullptr;
0118     QAction* m_putObjectLayer= nullptr;
0119     QAction* m_putCharacterLayer= nullptr;
0120     QAction* m_putGMLayer= nullptr;
0121 
0122     // z order action
0123     QAction* m_backOrderAction= nullptr;
0124     QAction* m_frontOrderAction= nullptr;
0125     QAction* m_lowerAction= nullptr;
0126     QAction* m_raiseAction= nullptr;
0127 
0128     QAction* m_removeSelection= nullptr;
0129 
0130     QAction* m_importImage= nullptr;
0131 
0132     Core::SelectableTool m_currentTool;
0133     PreferencesManager* m_preferences= nullptr;
0134     QPointF m_lastPoint;
0135     QPoint m_menuPoint;
0136     QGraphicsItem* m_centerOnItem= nullptr;
0137 };
0138 
0139 #endif // RGRAPHICSVIEW_H