From 5d2f6b98e2714182c8babe3de3c74aec1a2de98a Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 30 Sep 2014 15:20:24 -0700 Subject: [PATCH] Added erase buttons, initialize color editor on creation. --- interface/src/ui/MetavoxelEditor.cpp | 26 ++++++++++++++++++++-- interface/src/ui/MetavoxelEditor.h | 2 ++ libraries/metavoxels/src/MetavoxelUtil.cpp | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/MetavoxelEditor.cpp b/interface/src/ui/MetavoxelEditor.cpp index 1adf25448d..be603983f9 100644 --- a/interface/src/ui/MetavoxelEditor.cpp +++ b/interface/src/ui/MetavoxelEditor.cpp @@ -1344,8 +1344,14 @@ VoxelMaterialBoxTool::VoxelMaterialBoxTool(MetavoxelEditor* editor) : form->addRow(gridLayout); _snapToGrid->setChecked(true); - form->addRow("Color:", _color = new QColorEditor(this)); + QHBoxLayout* colorLayout = new QHBoxLayout(); + form->addRow("Color:", colorLayout); + colorLayout->addWidget(_color = new QColorEditor(this), 1); connect(_color, &QColorEditor::colorChanged, this, &VoxelMaterialBoxTool::clearTexture); + QPushButton* eraseButton = new QPushButton("Erase"); + colorLayout->addWidget(eraseButton); + connect(eraseButton, &QPushButton::clicked, this, &VoxelMaterialBoxTool::clearColor); + form->addRow(_materialEditor = new SharedObjectEditor(&MaterialObject::staticMetaObject, false)); connect(_materialEditor, &SharedObjectEditor::objectChanged, this, &VoxelMaterialBoxTool::updateTexture); } @@ -1376,6 +1382,11 @@ void VoxelMaterialBoxTool::applyValue(const glm::vec3& minimum, const glm::vec3& Application::getInstance()->getMetavoxels()->applyEdit(message, true); } +void VoxelMaterialBoxTool::clearColor() { + _color->setColor(QColor(0, 0, 0, 0)); + clearTexture(); +} + void VoxelMaterialBoxTool::clearTexture() { _materialEditor->setObject(new MaterialObject()); } @@ -1465,8 +1476,14 @@ bool SphereTool::eventFilter(QObject* watched, QEvent* event) { VoxelMaterialSphereTool::VoxelMaterialSphereTool(MetavoxelEditor* editor) : SphereTool(editor, "Set Voxel Material (Sphere)") { - _form->addRow("Color:", _color = new QColorEditor(this)); + QHBoxLayout* colorLayout = new QHBoxLayout(); + _form->addRow("Color:", colorLayout); + colorLayout->addWidget(_color = new QColorEditor(this), 1); connect(_color, &QColorEditor::colorChanged, this, &VoxelMaterialSphereTool::clearTexture); + QPushButton* eraseButton = new QPushButton("Erase"); + colorLayout->addWidget(eraseButton); + connect(eraseButton, &QPushButton::clicked, this, &VoxelMaterialSphereTool::clearColor); + _form->addRow(_materialEditor = new SharedObjectEditor(&MaterialObject::staticMetaObject, false)); connect(_materialEditor, &SharedObjectEditor::objectChanged, this, &VoxelMaterialSphereTool::updateTexture); } @@ -1493,6 +1510,11 @@ void VoxelMaterialSphereTool::applyValue(const glm::vec3& position, float radius Application::getInstance()->getMetavoxels()->applyEdit(message, true); } +void VoxelMaterialSphereTool::clearColor() { + _color->setColor(QColor(0, 0, 0, 0)); + clearTexture(); +} + void VoxelMaterialSphereTool::clearTexture() { _materialEditor->setObject(new MaterialObject()); } diff --git a/interface/src/ui/MetavoxelEditor.h b/interface/src/ui/MetavoxelEditor.h index bb8d05f330..21383ca01f 100644 --- a/interface/src/ui/MetavoxelEditor.h +++ b/interface/src/ui/MetavoxelEditor.h @@ -422,6 +422,7 @@ protected: private slots: + void clearColor(); void clearTexture(); void updateTexture(); void textureLoaded(); @@ -476,6 +477,7 @@ protected: private slots: + void clearColor(); void clearTexture(); void updateTexture(); void textureLoaded(); diff --git a/libraries/metavoxels/src/MetavoxelUtil.cpp b/libraries/metavoxels/src/MetavoxelUtil.cpp index e6b96e97b0..4aff339738 100644 --- a/libraries/metavoxels/src/MetavoxelUtil.cpp +++ b/libraries/metavoxels/src/MetavoxelUtil.cpp @@ -490,6 +490,7 @@ QColorEditor::QColorEditor(QWidget* parent) : QWidget(parent) { setLayout(layout); layout->addWidget(_button = new QPushButton()); connect(_button, SIGNAL(clicked()), SLOT(selectColor())); + setColor(QColor()); } void QColorEditor::setColor(const QColor& color) {