From 34668e8716fef96d36d879d8f947ab268525ca85 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Wed, 13 Nov 2013 23:04:51 -0800 Subject: [PATCH] add Paste To Voxel --- interface/src/Application.cpp | 32 +++++++++++++++++++------------- interface/src/Application.h | 2 +- interface/src/Menu.cpp | 33 ++++++++++++++++++++++++++++++++- interface/src/Menu.h | 2 ++ 4 files changed, 54 insertions(+), 15 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 71b63e8593..697d5d3b35 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1603,22 +1603,11 @@ void Application::copyVoxels() { } } -void Application::pasteVoxels() { - unsigned char* calculatedOctCode = NULL; - VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); - +void Application::pasteVoxelsToOctalCode(const unsigned char* octalCodeDestination) { // Recurse the clipboard tree, where everything is root relative, and send all the colored voxels to // the server as an set voxel message, this will also rebase the voxels to the new location SendVoxelsOperationArgs args; - - // we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the - // voxel size/position details. If we don't have an actual selectedNode then use the mouseVoxel to create a - // target octalCode for where the user is pointing. - if (selectedNode) { - args.newBaseOctCode = selectedNode->getOctalCode(); - } else { - args.newBaseOctCode = calculatedOctCode = pointToVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); - } + args.newBaseOctCode = octalCodeDestination; _sharedVoxelSystem.getTree()->recurseTreeWithOperation(sendVoxelsOperation, &args); @@ -1628,6 +1617,23 @@ void Application::pasteVoxels() { } _voxelEditSender.releaseQueuedMessages(); +} + +void Application::pasteVoxels() { + unsigned char* calculatedOctCode = NULL; + VoxelNode* selectedNode = _voxels.getVoxelAt(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); + + // we only need the selected voxel to get the newBaseOctCode, which we can actually calculate from the + // voxel size/position details. If we don't have an actual selectedNode then use the mouseVoxel to create a + // target octalCode for where the user is pointing. + const unsigned char* octalCodeDestination; + if (selectedNode) { + octalCodeDestination = selectedNode->getOctalCode(); + } else { + octalCodeDestination = calculatedOctCode = pointToVoxel(_mouseVoxel.x, _mouseVoxel.y, _mouseVoxel.z, _mouseVoxel.s); + } + + pasteVoxelsToOctalCode(octalCodeDestination); if (calculatedOctCode) { delete[] calculatedOctCode; diff --git a/interface/src/Application.h b/interface/src/Application.h index 61a65747af..78530ecea2 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -171,7 +171,7 @@ public: glm::vec2 getViewportDimensions() const{ return glm::vec2(_glWidget->width(),_glWidget->height()); } NodeToJurisdictionMap& getVoxelServerJurisdictions() { return _voxelServerJurisdictions; } - + void pasteVoxelsToOctalCode(const unsigned char* octalCodeDestination); public slots: void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 602d2131c2..d884f74630 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -486,7 +486,11 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(voxelProtoOptionsMenu, MenuOption::DestructiveAddVoxel); addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::ExtraDebugging); - + addActionToQMenuAndActionHash(developerMenu, MenuOption::PasteToVoxel, + Qt::CTRL | Qt::SHIFT | Qt::Key_V, + this, + SLOT(pasteToVoxel())); + #ifndef Q_OS_MAC QMenu* helpMenu = addMenu("Help"); @@ -958,6 +962,33 @@ void Menu::goToUser() { sendFakeEnterEvent(); } +void Menu::pasteToVoxel() { + QInputDialog pasteToOctalCodeDialog(Application::getInstance()->getWindow()); + pasteToOctalCodeDialog.setWindowTitle("Paste to Voxel"); + pasteToOctalCodeDialog.setLabelText("Octal Code:"); + QString octalCode = ""; + pasteToOctalCodeDialog.setTextValue(octalCode); + pasteToOctalCodeDialog.setWindowFlags(Qt::Sheet); + pasteToOctalCodeDialog.resize(pasteToOctalCodeDialog.parentWidget()->size().width() * DIALOG_RATIO_OF_WINDOW, + pasteToOctalCodeDialog.size().height()); + + int dialogReturn = pasteToOctalCodeDialog.exec(); + if (dialogReturn == QDialog::Accepted && !pasteToOctalCodeDialog.textValue().isEmpty()) { + // we got an octalCode to paste to... + QString locationToPaste = pasteToOctalCodeDialog.textValue(); + unsigned char* octalCodeDestination = hexStringToOctalCode(locationToPaste); + + // check to see if it was a legit octcode... + if (locationToPaste == octalCodeToHexString(octalCodeDestination)) { + Application::getInstance()->pasteVoxelsToOctalCode(octalCodeDestination); + } else { + qDebug() << "problem with octcode...\n"; + } + } + + sendFakeEnterEvent(); +} + void Menu::bandwidthDetails() { if (! _bandwidthDialog) { _bandwidthDialog = new BandwidthDialog(Application::getInstance()->getGLWidget(), diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 6e70fb44e4..7058cc1d04 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -76,6 +76,7 @@ public slots: void importSettings(); void exportSettings(); void goToUser(); + void pasteToVoxel(); private slots: void aboutApp(); @@ -212,6 +213,7 @@ namespace MenuOption { const QString Oscilloscope = "Audio Oscilloscope"; const QString Pair = "Pair"; const QString PasteVoxels = "Paste"; + const QString PasteToVoxel = "Paste to Voxel..."; const QString PipelineWarnings = "Show Render Pipeline Warnings"; const QString Preferences = "Preferences..."; const QString RandomizeVoxelColors = "Randomize Voxel TRUE Colors";