mirror of https://github.com/OpenMW/openmw.git
Transient land shape editing
parent
262d87846c
commit
16138fc896
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,157 @@
|
|||||||
|
#ifndef CSV_RENDER_TERRAINSHAPEMODE_H
|
||||||
|
#define CSV_RENDER_TERRAINSHAPEMODE_H
|
||||||
|
|
||||||
|
#include "editmode.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QEvent>
|
||||||
|
|
||||||
|
#ifndef Q_MOC_RUN
|
||||||
|
#include "../../model/world/data.hpp"
|
||||||
|
#include "../../model/world/land.hpp"
|
||||||
|
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
#include "../../model/world/commands.hpp"
|
||||||
|
#include "../../model/world/idtable.hpp"
|
||||||
|
#include "../../model/world/landtexture.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "terrainselection.hpp"
|
||||||
|
|
||||||
|
namespace CSVWidget
|
||||||
|
{
|
||||||
|
class SceneToolShapeBrush;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class PagedWorldspaceWidget;
|
||||||
|
|
||||||
|
/// \brief EditMode for handling the terrain shape editing
|
||||||
|
class TerrainShapeMode : public EditMode
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum InteractionType
|
||||||
|
{
|
||||||
|
InteractionType_PrimaryEdit,
|
||||||
|
InteractionType_PrimarySelect,
|
||||||
|
InteractionType_SecondaryEdit,
|
||||||
|
InteractionType_SecondarySelect,
|
||||||
|
InteractionType_None
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Editmode for terrain shape grid
|
||||||
|
TerrainShapeMode(WorldspaceWidget*, osg::Group* parentNode, QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
void primaryOpenPressed (const WorldspaceHitResult& hit);
|
||||||
|
|
||||||
|
/// Create single command for one-click shape editing
|
||||||
|
void primaryEditPressed (const WorldspaceHitResult& hit);
|
||||||
|
|
||||||
|
/// Open brush settings window
|
||||||
|
void primarySelectPressed(const WorldspaceHitResult&);
|
||||||
|
|
||||||
|
void secondarySelectPressed(const WorldspaceHitResult&);
|
||||||
|
|
||||||
|
void activate(CSVWidget::SceneToolbar*);
|
||||||
|
void deactivate(CSVWidget::SceneToolbar*);
|
||||||
|
|
||||||
|
/// Start shape editing command macro
|
||||||
|
virtual bool primaryEditStartDrag (const QPoint& pos);
|
||||||
|
|
||||||
|
virtual bool secondaryEditStartDrag (const QPoint& pos);
|
||||||
|
virtual bool primarySelectStartDrag (const QPoint& pos);
|
||||||
|
virtual bool secondarySelectStartDrag (const QPoint& pos);
|
||||||
|
|
||||||
|
/// Handle shape edit behavior during dragging
|
||||||
|
virtual void drag (const QPoint& pos, int diffX, int diffY, double speedFactor);
|
||||||
|
|
||||||
|
/// End shape editing command macro
|
||||||
|
virtual void dragCompleted(const QPoint& pos);
|
||||||
|
|
||||||
|
/// Cancel shape editing, and reset all pending changes
|
||||||
|
virtual void dragAborted();
|
||||||
|
|
||||||
|
virtual void dragWheel (int diff, double speedFactor);
|
||||||
|
virtual void dragMoveEvent (QDragMoveEvent *event);
|
||||||
|
|
||||||
|
/// Handle brush mechanics for shape editing
|
||||||
|
void editTerrainShapeGrid (const std::pair<int, int>& vertexCoords, bool dragOperation);
|
||||||
|
|
||||||
|
/// Do a single height alteration for transient shape edit map
|
||||||
|
void alterHeight(const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, float alteredHeight, bool useTool = true);
|
||||||
|
|
||||||
|
/// Do a single smoothing height alteration for transient shape edit map
|
||||||
|
void smoothHeight(const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, int toolStrength);
|
||||||
|
|
||||||
|
/// Do a single flattening height alteration for transient shape edit map
|
||||||
|
void flattenHeight(const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, int toolStrength, int targetHeight);
|
||||||
|
|
||||||
|
/// Update the key values used in height calculations
|
||||||
|
void updateKeyHeightValues(const CSMWorld::CellCoordinates& cellCoords, int inCellX, int inCellY, float* thisHeight,
|
||||||
|
float* thisAlteredHeight, float* leftHeight, float* leftAlteredHeight, float* upHeight, float* upAlteredHeight);
|
||||||
|
|
||||||
|
/// Bind edge vertices to next cells
|
||||||
|
void fixEdges(const CSMWorld::CellCoordinates& cellCoords);
|
||||||
|
|
||||||
|
/// Check that the edit doesn't break save format limits, fix if necessary
|
||||||
|
void limitAlteredHeights(const CSMWorld::CellCoordinates& cellCoords);
|
||||||
|
|
||||||
|
/// Handle brush mechanics for terrain shape selection
|
||||||
|
void selectTerrainShapes (const std::pair<int, int>& vertexCoords, unsigned char selectMode, bool dragOperation);
|
||||||
|
|
||||||
|
/// Push terrain shape edits to command macro
|
||||||
|
void pushEditToCommand (const CSMWorld::LandHeightsColumn::DataType& newLandGrid, CSMDoc::Document& document,
|
||||||
|
CSMWorld::IdTable& landTable, std::string cellId);
|
||||||
|
|
||||||
|
/// Push land normals edits to command macro
|
||||||
|
void pushNormalsEditToCommand(const CSMWorld::LandNormalsColumn::DataType& newLandGrid, CSMDoc::Document& document,
|
||||||
|
CSMWorld::IdTable& landTable, std::string cellId);
|
||||||
|
|
||||||
|
/// Create new cell and land if needed
|
||||||
|
bool allowLandShapeEditing(std::string textureFileName);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string mCellId;
|
||||||
|
std::string mBrushTexture;
|
||||||
|
int mBrushSize;
|
||||||
|
int mBrushShape;
|
||||||
|
std::vector<std::pair<int, int>> mCustomBrushShape;
|
||||||
|
CSVWidget::SceneToolShapeBrush *mShapeBrushScenetool;
|
||||||
|
int mDragMode;
|
||||||
|
osg::Group* mParentNode;
|
||||||
|
bool mIsEditing;
|
||||||
|
std::unique_ptr<TerrainSelection> mTerrainShapeSelection;
|
||||||
|
int mTotalDiffY;
|
||||||
|
std::vector<CSMWorld::CellCoordinates> mAlteredCells;
|
||||||
|
osg::Vec3d mEditingPos;
|
||||||
|
int mShapeEditTool;
|
||||||
|
int mShapeEditToolStrength;
|
||||||
|
int mTargetHeight;
|
||||||
|
|
||||||
|
const int cellSize {ESM::Land::REAL_SIZE};
|
||||||
|
const int landSize {ESM::Land::LAND_SIZE};
|
||||||
|
const int landTextureSize {ESM::Land::LAND_TEXTURE_SIZE};
|
||||||
|
|
||||||
|
PagedWorldspaceWidget& getPagedWorldspaceWidget();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void passBrushTexture(std::string brushTexture);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
//void handleDropEvent(QDropEvent *event);
|
||||||
|
void setBrushSize(int brushSize);
|
||||||
|
void setBrushShape(int brushShape);
|
||||||
|
void setShapeEditTool(int shapeEditTool);
|
||||||
|
void setShapeEditToolStrength(int shapeEditToolStrength);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,265 @@
|
|||||||
|
#include "scenetoolshapebrush.hpp"
|
||||||
|
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QSlider>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QDropEvent>
|
||||||
|
#include <QButtonGroup>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QDragEnterEvent>
|
||||||
|
#include <QDrag>
|
||||||
|
#include <QTableWidget>
|
||||||
|
#include <QHeaderView>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QSizePolicy>
|
||||||
|
|
||||||
|
#include "scenetool.hpp"
|
||||||
|
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
#include "../../model/prefs/state.hpp"
|
||||||
|
#include "../../model/world/commands.hpp"
|
||||||
|
#include "../../model/world/data.hpp"
|
||||||
|
#include "../../model/world/idcollection.hpp"
|
||||||
|
#include "../../model/world/idtable.hpp"
|
||||||
|
#include "../../model/world/landtexture.hpp"
|
||||||
|
#include "../../model/world/universalid.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
CSVWidget::ShapeBrushSizeControls::ShapeBrushSizeControls(const QString &title, QWidget *parent)
|
||||||
|
: QGroupBox(title, parent)
|
||||||
|
{
|
||||||
|
mBrushSizeSlider = new QSlider(Qt::Horizontal);
|
||||||
|
mBrushSizeSlider->setTickPosition(QSlider::TicksBothSides);
|
||||||
|
mBrushSizeSlider->setTickInterval(10);
|
||||||
|
mBrushSizeSlider->setRange(1, CSMPrefs::get()["3D Scene Editing"]["shapebrush-maximumsize"].toInt());
|
||||||
|
mBrushSizeSlider->setSingleStep(1);
|
||||||
|
|
||||||
|
mBrushSizeSpinBox = new QSpinBox;
|
||||||
|
mBrushSizeSpinBox->setRange(1, CSMPrefs::get()["3D Scene Editing"]["shapebrush-maximumsize"].toInt());
|
||||||
|
mBrushSizeSpinBox->setSingleStep(1);
|
||||||
|
|
||||||
|
mLayoutSliderSize = new QHBoxLayout;
|
||||||
|
mLayoutSliderSize->addWidget(mBrushSizeSlider);
|
||||||
|
mLayoutSliderSize->addWidget(mBrushSizeSpinBox);
|
||||||
|
|
||||||
|
connect(mBrushSizeSlider, SIGNAL(valueChanged(int)), mBrushSizeSpinBox, SLOT(setValue(int)));
|
||||||
|
connect(mBrushSizeSpinBox, SIGNAL(valueChanged(int)), mBrushSizeSlider, SLOT(setValue(int)));
|
||||||
|
|
||||||
|
setLayout(mLayoutSliderSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWidget::ShapeBrushWindow::ShapeBrushWindow(CSMDoc::Document& document, QWidget *parent)
|
||||||
|
: QFrame(parent, Qt::Popup),
|
||||||
|
mBrushShape(0),
|
||||||
|
mBrushSize(0),
|
||||||
|
mDocument(document)
|
||||||
|
{
|
||||||
|
mButtonPoint = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-point")), "", this);
|
||||||
|
mButtonSquare = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-square")), "", this);
|
||||||
|
mButtonCircle = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-circle")), "", this);
|
||||||
|
mButtonCustom = new QPushButton(QIcon (QPixmap (":scenetoolbar/brush-custom")), "", this);
|
||||||
|
|
||||||
|
mSizeSliders = new ShapeBrushSizeControls("Brush size", this);
|
||||||
|
|
||||||
|
QVBoxLayout *layoutMain = new QVBoxLayout;
|
||||||
|
layoutMain->setSpacing(0);
|
||||||
|
layoutMain->setContentsMargins(4,0,4,4);
|
||||||
|
|
||||||
|
QHBoxLayout *layoutHorizontal = new QHBoxLayout;
|
||||||
|
layoutHorizontal->setSpacing(0);
|
||||||
|
layoutHorizontal->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
|
||||||
|
configureButtonInitialSettings(mButtonPoint);
|
||||||
|
configureButtonInitialSettings(mButtonSquare);
|
||||||
|
configureButtonInitialSettings(mButtonCircle);
|
||||||
|
configureButtonInitialSettings(mButtonCustom);
|
||||||
|
|
||||||
|
mButtonPoint->setToolTip (toolTipPoint);
|
||||||
|
mButtonSquare->setToolTip (toolTipSquare);
|
||||||
|
mButtonCircle->setToolTip (toolTipCircle);
|
||||||
|
mButtonCustom->setToolTip (toolTipCustom);
|
||||||
|
|
||||||
|
QButtonGroup* brushButtonGroup = new QButtonGroup(this);
|
||||||
|
brushButtonGroup->addButton(mButtonPoint);
|
||||||
|
brushButtonGroup->addButton(mButtonSquare);
|
||||||
|
brushButtonGroup->addButton(mButtonCircle);
|
||||||
|
brushButtonGroup->addButton(mButtonCustom);
|
||||||
|
|
||||||
|
brushButtonGroup->setExclusive(true);
|
||||||
|
|
||||||
|
layoutHorizontal->addWidget(mButtonPoint, 0, Qt::AlignTop);
|
||||||
|
layoutHorizontal->addWidget(mButtonSquare, 0, Qt::AlignTop);
|
||||||
|
layoutHorizontal->addWidget(mButtonCircle, 0, Qt::AlignTop);
|
||||||
|
layoutHorizontal->addWidget(mButtonCustom, 0, Qt::AlignTop);
|
||||||
|
|
||||||
|
mHorizontalGroupBox = new QGroupBox(tr(""));
|
||||||
|
mHorizontalGroupBox->setLayout(layoutHorizontal);
|
||||||
|
|
||||||
|
mToolSelector = new QComboBox(this);
|
||||||
|
mToolSelector->addItem(tr("Height (drag)"));
|
||||||
|
mToolSelector->addItem(tr("Height, raise (paint)"));
|
||||||
|
mToolSelector->addItem(tr("Height, lower (paint)"));
|
||||||
|
mToolSelector->addItem(tr("Smooth (paint)"));
|
||||||
|
mToolSelector->addItem(tr("Flatten (paint)"));
|
||||||
|
|
||||||
|
QLabel *brushStrengthLabel = new QLabel(this);
|
||||||
|
brushStrengthLabel->setText("Brush strength:");
|
||||||
|
|
||||||
|
mToolStrengthSlider = new QSlider(Qt::Horizontal);
|
||||||
|
mToolStrengthSlider->setTickPosition(QSlider::TicksBothSides);
|
||||||
|
mToolStrengthSlider->setTickInterval(8);
|
||||||
|
mToolStrengthSlider->setRange(8, 128);
|
||||||
|
mToolStrengthSlider->setSingleStep(8);
|
||||||
|
|
||||||
|
layoutMain->addWidget(mHorizontalGroupBox);
|
||||||
|
layoutMain->addWidget(mSizeSliders);
|
||||||
|
layoutMain->addWidget(mToolSelector);
|
||||||
|
layoutMain->addWidget(brushStrengthLabel);
|
||||||
|
layoutMain->addWidget(mToolStrengthSlider);
|
||||||
|
|
||||||
|
setLayout(layoutMain);
|
||||||
|
|
||||||
|
connect(mButtonPoint, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
||||||
|
connect(mButtonSquare, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
||||||
|
connect(mButtonCircle, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
||||||
|
connect(mButtonCustom, SIGNAL(clicked()), this, SLOT(setBrushShape()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::ShapeBrushWindow::configureButtonInitialSettings(QPushButton *button)
|
||||||
|
{
|
||||||
|
button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||||
|
button->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
button->setIconSize (QSize (48-6, 48-6));
|
||||||
|
button->setFixedSize (48, 48);
|
||||||
|
button->setCheckable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::ShapeBrushWindow::setBrushSize(int brushSize)
|
||||||
|
{
|
||||||
|
mBrushSize = brushSize;
|
||||||
|
emit passBrushSize(mBrushSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::ShapeBrushWindow::setBrushShape()
|
||||||
|
{
|
||||||
|
if(mButtonPoint->isChecked()) mBrushShape = 0;
|
||||||
|
if(mButtonSquare->isChecked()) mBrushShape = 1;
|
||||||
|
if(mButtonCircle->isChecked()) mBrushShape = 2;
|
||||||
|
if(mButtonCustom->isChecked()) mBrushShape = 3;
|
||||||
|
emit passBrushShape(mBrushShape);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolShapeBrush::adjustToolTips()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVWidget::SceneToolShapeBrush::SceneToolShapeBrush (SceneToolbar *parent, const QString& toolTip, CSMDoc::Document& document)
|
||||||
|
: SceneTool (parent, Type_TopAction),
|
||||||
|
mToolTip (toolTip),
|
||||||
|
mDocument (document),
|
||||||
|
mShapeBrushWindow(new ShapeBrushWindow(document, this))
|
||||||
|
{
|
||||||
|
setAcceptDrops(true);
|
||||||
|
connect(mShapeBrushWindow, SIGNAL(passBrushShape(int)), this, SLOT(setButtonIcon(int)));
|
||||||
|
setButtonIcon(mShapeBrushWindow->mBrushShape);
|
||||||
|
|
||||||
|
mPanel = new QFrame (this, Qt::Popup);
|
||||||
|
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout (mPanel);
|
||||||
|
|
||||||
|
layout->setContentsMargins (QMargins (0, 0, 0, 0));
|
||||||
|
|
||||||
|
mTable = new QTableWidget (0, 2, this);
|
||||||
|
|
||||||
|
mTable->setShowGrid (true);
|
||||||
|
mTable->verticalHeader()->hide();
|
||||||
|
mTable->horizontalHeader()->hide();
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||||
|
mTable->horizontalHeader()->setSectionResizeMode (0, QHeaderView::Stretch);
|
||||||
|
mTable->horizontalHeader()->setSectionResizeMode (1, QHeaderView::Stretch);
|
||||||
|
#else
|
||||||
|
mTable->horizontalHeader()->setResizeMode (0, QHeaderView::Stretch);
|
||||||
|
mTable->horizontalHeader()->setResizeMode (1, QHeaderView::Stretch);
|
||||||
|
#endif
|
||||||
|
mTable->setSelectionMode (QAbstractItemView::NoSelection);
|
||||||
|
|
||||||
|
layout->addWidget (mTable);
|
||||||
|
|
||||||
|
connect (mTable, SIGNAL (clicked (const QModelIndex&)),
|
||||||
|
this, SLOT (clicked (const QModelIndex&)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolShapeBrush::setButtonIcon (int brushShape)
|
||||||
|
{
|
||||||
|
QString tooltip = "Change brush settings <p>Currently selected: ";
|
||||||
|
|
||||||
|
switch (brushShape)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
|
||||||
|
setIcon (QIcon (QPixmap (":scenetoolbar/brush-point")));
|
||||||
|
tooltip += mShapeBrushWindow->toolTipPoint;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
|
||||||
|
setIcon (QIcon (QPixmap (":scenetoolbar/brush-square")));
|
||||||
|
tooltip += mShapeBrushWindow->toolTipSquare;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
|
||||||
|
setIcon (QIcon (QPixmap (":scenetoolbar/brush-circle")));
|
||||||
|
tooltip += mShapeBrushWindow->toolTipCircle;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
|
||||||
|
setIcon (QIcon (QPixmap (":scenetoolbar/brush-custom")));
|
||||||
|
tooltip += mShapeBrushWindow->toolTipCustom;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
setToolTip (tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolShapeBrush::showPanel (const QPoint& position)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolShapeBrush::updatePanel ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolShapeBrush::clicked (const QModelIndex& index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolShapeBrush::activate ()
|
||||||
|
{
|
||||||
|
QPoint position = QCursor::pos();
|
||||||
|
mShapeBrushWindow->mSizeSliders->mBrushSizeSlider->setRange(1, CSMPrefs::get()["3D Scene Editing"]["shapebrush-maximumsize"].toInt());
|
||||||
|
mShapeBrushWindow->mSizeSliders->mBrushSizeSpinBox->setRange(1, CSMPrefs::get()["3D Scene Editing"]["shapebrush-maximumsize"].toInt());
|
||||||
|
mShapeBrushWindow->move (position);
|
||||||
|
mShapeBrushWindow->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVWidget::SceneToolShapeBrush::dragEnterEvent (QDragEnterEvent *event)
|
||||||
|
{
|
||||||
|
emit passEvent(event);
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
void CSVWidget::SceneToolShapeBrush::dropEvent (QDropEvent *event)
|
||||||
|
{
|
||||||
|
emit passEvent(event);
|
||||||
|
event->accept();
|
||||||
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
#ifndef CSV_WIDGET_SCENETOOLSHAPEBRUSH_H
|
||||||
|
#define CSV_WIDGET_SCENETOOLSHAPEBRUSH_H
|
||||||
|
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QFrame>
|
||||||
|
#include <QModelIndex>
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QSlider>
|
||||||
|
#include <QEvent>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#ifndef Q_MOC_RUN
|
||||||
|
#include "scenetool.hpp"
|
||||||
|
|
||||||
|
#include "../../model/doc/document.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class QTableWidget;
|
||||||
|
|
||||||
|
namespace CSVRender
|
||||||
|
{
|
||||||
|
class TerrainShapeMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace CSVWidget
|
||||||
|
{
|
||||||
|
class SceneToolShapeBrush;
|
||||||
|
|
||||||
|
/// \brief Layout-box for some brush button settings
|
||||||
|
class ShapeBrushSizeControls : public QGroupBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ShapeBrushSizeControls(const QString &title, QWidget *parent);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QHBoxLayout *mLayoutSliderSize;
|
||||||
|
QSlider *mBrushSizeSlider;
|
||||||
|
QSpinBox *mBrushSizeSpinBox;
|
||||||
|
|
||||||
|
friend class SceneToolShapeBrush;
|
||||||
|
friend class CSVRender::TerrainShapeMode;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SceneToolShapeBrush;
|
||||||
|
|
||||||
|
/// \brief Brush settings window
|
||||||
|
class ShapeBrushWindow : public QFrame
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ShapeBrushWindow(CSMDoc::Document& document, QWidget *parent = 0);
|
||||||
|
void configureButtonInitialSettings(QPushButton *button);
|
||||||
|
|
||||||
|
const QString toolTipPoint = "Paint single point";
|
||||||
|
const QString toolTipSquare = "Paint with square brush";
|
||||||
|
const QString toolTipCircle = "Paint with circle brush";
|
||||||
|
const QString toolTipCustom = "Paint custom selection (not implemented yet)";
|
||||||
|
|
||||||
|
private:
|
||||||
|
int mBrushShape;
|
||||||
|
int mBrushSize;
|
||||||
|
CSMDoc::Document& mDocument;
|
||||||
|
QGroupBox *mHorizontalGroupBox;
|
||||||
|
QComboBox *mToolSelector;
|
||||||
|
QSlider *mToolStrengthSlider;
|
||||||
|
QPushButton *mButtonPoint;
|
||||||
|
QPushButton *mButtonSquare;
|
||||||
|
QPushButton *mButtonCircle;
|
||||||
|
QPushButton *mButtonCustom;
|
||||||
|
ShapeBrushSizeControls* mSizeSliders;
|
||||||
|
|
||||||
|
friend class SceneToolShapeBrush;
|
||||||
|
friend class CSVRender::TerrainShapeMode;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setBrushShape();
|
||||||
|
void setBrushSize(int brushSize);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void passBrushSize (int brushSize);
|
||||||
|
void passBrushShape(int brushShape);
|
||||||
|
};
|
||||||
|
|
||||||
|
class SceneToolShapeBrush : public SceneTool
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
QString mToolTip;
|
||||||
|
CSMDoc::Document& mDocument;
|
||||||
|
QFrame *mPanel;
|
||||||
|
QTableWidget *mTable;
|
||||||
|
ShapeBrushWindow *mShapeBrushWindow;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void adjustToolTips();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
SceneToolShapeBrush (SceneToolbar *parent, const QString& toolTip, CSMDoc::Document& document);
|
||||||
|
|
||||||
|
virtual void showPanel (const QPoint& position);
|
||||||
|
void updatePanel ();
|
||||||
|
|
||||||
|
void dropEvent (QDropEvent *event);
|
||||||
|
void dragEnterEvent (QDragEnterEvent *event);
|
||||||
|
|
||||||
|
friend class CSVRender::TerrainShapeMode;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setButtonIcon(int brushShape);
|
||||||
|
void clicked (const QModelIndex& index);
|
||||||
|
virtual void activate();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void passEvent(QDropEvent *event);
|
||||||
|
void passEvent(QDragEnterEvent *event);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue