1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-15 00:40:02 +00:00
OpenMW/apps/opencs/view/render/terraintexturemode.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

132 lines
4.2 KiB
C++
Raw Normal View History

2018-04-15 14:47:31 +03:00
#ifndef CSV_RENDER_TERRAINTEXTUREMODE_H
#define CSV_RENDER_TERRAINTEXTUREMODE_H
#include "editmode.hpp"
#include <memory>
2018-04-15 14:47:31 +03:00
#include <string>
#include <QEvent>
#include <QWidget>
#ifndef Q_MOC_RUN
2018-04-19 18:00:47 +03:00
#include "../../model/doc/document.hpp"
2022-08-19 19:19:42 +02:00
#include "../../model/world/columnimp.hpp"
2018-04-19 18:00:47 +03:00
#include "../../model/world/idtable.hpp"
#include "../widget/brushshapes.hpp"
#include "brushdraw.hpp"
#endif
2018-04-19 18:00:47 +03:00
#include "terrainselection.hpp"
2019-04-07 23:11:13 +03:00
namespace osg
{
class Group;
}
2018-04-15 14:47:31 +03:00
namespace CSVWidget
{
class SceneToolTextureBrush;
2018-04-15 14:47:31 +03:00
}
namespace CSVRender
{
class TerrainTextureMode : public EditMode
{
Q_OBJECT
public:
enum InteractionType
2022-09-22 21:26:05 +03:00
{
InteractionType_PrimaryEdit,
InteractionType_PrimarySelect,
InteractionType_SecondaryEdit,
InteractionType_SecondarySelect,
InteractionType_None
2022-09-22 21:26:05 +03:00
};
2018-04-15 14:47:31 +03:00
/// \brief Editmode for terrain texture grid
TerrainTextureMode(WorldspaceWidget*, osg::Group* parentNode, QWidget* parent = nullptr);
void primaryOpenPressed(const WorldspaceHitResult& hit) override;
2018-04-15 14:47:31 +03:00
/// \brief Create single command for one-click texture editing
void primaryEditPressed(const WorldspaceHitResult& hit) override;
/// \brief Open brush settings window
void primarySelectPressed(const WorldspaceHitResult&) override;
2018-04-15 18:49:33 +03:00
void secondarySelectPressed(const WorldspaceHitResult&) override;
void activate(CSVWidget::SceneToolbar*) override;
void deactivate(CSVWidget::SceneToolbar*) override;
2018-04-15 14:47:31 +03:00
/// \brief Start texture editing command macro
bool primaryEditStartDrag(const QPoint& pos) override;
2018-04-15 14:47:31 +03:00
bool secondaryEditStartDrag(const QPoint& pos) override;
bool primarySelectStartDrag(const QPoint& pos) override;
bool secondarySelectStartDrag(const QPoint& pos) override;
/// \brief Handle texture edit behavior during dragging
void drag(const QPoint& pos, int diffX, int diffY, double speedFactor) override;
/// \brief End texture editing command macro
void dragCompleted(const QPoint& pos) override;
void dragAborted() override;
void dragWheel(int diff, double speedFactor) override;
void dragMoveEvent(QDragMoveEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
2018-04-15 14:47:31 +03:00
std::shared_ptr<TerrainSelection> getTerrainSelection();
2022-09-22 21:26:05 +03:00
private:
/// \brief Handle brush mechanics, maths regarding worldspace hit etc.
void editTerrainTextureGrid(const WorldspaceHitResult& hit);
/// \brief Check if global selection coordinate belongs to cell in view
2018-04-17 20:48:58 +03:00
bool isInCellSelection(int globalSelectionX, int globalSelectionY);
2019-05-06 12:56:04 +03:00
/// \brief Handle brush mechanics for texture selection
void selectTerrainTextures(const std::pair<int, int>& texCoords, unsigned char selectMode);
2019-05-06 12:56:04 +03:00
/// \brief Push texture edits to command macro
void pushEditToCommand(CSMWorld::LandTexturesColumn::DataType& newLandGrid, CSMDoc::Document& document,
CSMWorld::IdTable& landTable, std::string cellId);
/// \brief Create new land texture record from texture asset
2018-04-19 18:00:47 +03:00
void createTexture(std::string textureFileName);
2018-04-17 20:48:58 +03:00
/// \brief Create new cell and land if needed
bool allowLandTextureEditing(std::string textureFileName);
std::string mCellId;
std::string mBrushTexture;
int mBrushSize;
CSVWidget::BrushShape mBrushShape;
std::unique_ptr<BrushDraw> mBrushDraw;
std::vector<std::pair<int, int>> mCustomBrushShape;
CSVWidget::SceneToolTextureBrush* mTextureBrushScenetool;
int mDragMode;
osg::Group* mParentNode;
bool mIsEditing;
std::shared_ptr<TerrainSelection> mTerrainTextureSelection;
const int cellSize{ ESM::Land::REAL_SIZE };
const int landTextureSize{ ESM::Land::LAND_TEXTURE_SIZE };
2018-04-15 14:47:31 +03:00
2018-04-15 18:49:33 +03:00
signals:
void passBrushTexture(std::string brushTexture);
2018-04-15 14:47:31 +03:00
public slots:
void handleDropEvent(QDropEvent* event);
2018-04-15 18:49:33 +03:00
void setBrushSize(int brushSize);
void setBrushShape(CSVWidget::BrushShape brushShape);
2018-05-10 21:58:36 +03:00
void setBrushTexture(std::string brushShape);
2018-04-15 14:47:31 +03:00
};
}
#endif