/**************************************************************************** Copyright (C) 2010-2012 the Office National des ForĂȘts (ONF), France All rights reserved. Contact : alexandre.piboule@onf.fr Developers : Alexandre PIBOULE (ONF) This file is part of PluginONF library. PluginONF is free library: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. PluginONF 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 Lesser General Public License along with PluginONF. If not, see . *****************************************************************************/ #ifndef ONF_ACTIONSELECTCELLSINGRID3D_H #define ONF_ACTIONSELECTCELLSINGRID3D_H #include "views/actions/onf_actionselectcellsingrid3doptions.h" #include "ctlibaction/ct_actions/abstract/ct_abstractactionforgraphicsview.h" #include "ct_itemdrawable/abstract/ct_abstractgrid3d.h" #include "ct_itemdrawable/ct_grid3d.h" #include class ONF_ActionSelectCellsInGrid3D : public CT_AbstractActionForGraphicsView { Q_OBJECT public: ONF_ActionSelectCellsInGrid3D(const CT_AbstractGrid3D* refGrid, CT_Grid3D* boolGrid); QString uniqueName() const override; QString title() const override; QString description() const override; QIcon icon() const override; QString type() const override; void init() override; void initActiveGridForLevel(); bool mousePressEvent(QMouseEvent *e) override; bool mouseMoveEvent(QMouseEvent *e) override; bool mouseReleaseEvent(QMouseEvent *e) override; bool wheelEvent(QWheelEvent *e) override; bool keyPressEvent(QKeyEvent *e) override; bool keyReleaseEvent(QKeyEvent *e) override; void draw(GraphicsViewInterface &view, PainterInterface &painter) override; void drawOverlay(GraphicsViewInterface &view, QPainter &painter) override; CT_AbstractAction* createInstance() const override; QList computeExtends(int originColumn, int originRow); QList computeColonize(int originColumn, int originRow); QList computeExtends3D(size_t index); QList computeColonize3D(size_t index); public slots: void updateLevel(int level); void updateThickness(int thickness); void updateDrawing(); void updateCumulMode(ONF_ActionSelectCellsInGrid3DOptions::CumulateMode mode); void updateSelectionMode(ONF_ActionSelectCellsInGrid3DOptions::GridSelectionMode mode); void copyUpwards(); void copyFull(); void change2D3DMode(bool mode3D); void changeCoef(double coef); void changeGridColor(QColor color); void selectNotEmptyCells(); void createConvexHull(); private: int m_status; size_t _lastIndex; bool _validLastIndex; ONF_ActionSelectCellsInGrid3DOptions::GridSelectionMode _previewMode; ONF_ActionSelectCellsInGrid3DOptions::CumulateMode _cumulMode; QList _candidates; bool _refState; bool _mode3D; const CT_AbstractGrid3D* _refGrid; CT_Grid3D* _boolGrid; std::vector _active2DGrid; double _activeMin; double _activeMax; int _level; int _thickness; double _reductionCoef; QColor _gridColor; bool getCoordsInActiveLevelForMousePosition(const QMouseEvent *e, double &x, double &y, double &z); bool getIndexInGridForMousePosition(const QMouseEvent *e, size_t &index); void updateSelection(const double x, const double y, const double z); void updateSelection(const size_t index); void copyLevel(int refLevel, int first, int last); void draw2D(GraphicsViewInterface &view, PainterInterface &painter); void draw3D(GraphicsViewInterface &view, PainterInterface &painter); void appendIfNotNulValue2D(QList &result, int col, int lin); void appendIfCoherentRefState(QList &result, int col, int lin, int lev); void appendIfNotNulValue3D(QList &result, int col, int lin, int lev); }; #endif // ONF_ACTIONSELECTCELLSINGRID3D_H