From 63c954dedc0508f7622d66b5ed61972caf49ca84 Mon Sep 17 00:00:00 2001 From: brunoherbelin Date: Wed, 17 Mar 2021 18:49:20 +0100 Subject: [PATCH] Improved overlay grid --- GeometryView.cpp | 32 +++----- TextureView.cpp | 30 +++---- rsc/mesh/icon_grid.ply | 180 +++++++++++++++++++++++++++++------------ 3 files changed, 148 insertions(+), 94 deletions(-) diff --git a/GeometryView.cpp b/GeometryView.cpp index 1b56739..06ebb64 100644 --- a/GeometryView.cpp +++ b/GeometryView.cpp @@ -55,9 +55,8 @@ GeometryView::GeometryView() : View(GEOMETRY) scene.fg()->attach(overlay_position_); overlay_position_->visible_ = false; // cross to show the axis for POSITION - overlay_position_cross_ = new Symbol(Symbol::CROSS); - overlay_position_cross_->rotation_ = glm::vec3(0.f, 0.f, M_PI_4); - overlay_position_cross_->scale_ = glm::vec3(0.3f, 0.3f, 1.f); + overlay_position_cross_ = new Symbol(Symbol::GRID); + overlay_position_cross_->scale_ = glm::vec3(0.5f, 0.5f, 1.f); scene.fg()->attach(overlay_position_cross_); overlay_position_cross_->visible_ = false; // 'clock' : tic marks every 10 degrees for ROTATION @@ -91,10 +90,11 @@ GeometryView::GeometryView() : View(GEOMETRY) // with dark background Group *g = new Group; s = new Symbol(Symbol::GRID); + s->scale_ = glm::vec3(1.655f, 1.655f, 1.f); g->attach(s); s = new Symbol(Symbol::SQUARE_POINT); s->color = glm::vec4(0.f, 0.f, 0.f, 0.1f); - s->scale_ = glm::vec3(18.f, 18.f, 1.f); + s->scale_ = glm::vec3(17.f, 17.f, 1.f); s->translation_.z = -0.1; g->attach(s); overlay_scaling_grid_ = g; @@ -953,24 +953,12 @@ View::Cursor GeometryView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::p // discretized translation with ALT if (UserInterface::manager().altModifier()) { sourceNode->translation_.x = ROUND(sourceNode->translation_.x, 10.f); - sourceNode->translation_.y = ROUND(sourceNode->translation_.y, 10.f); -// // + SHIFT: single axis movement -// overlay_position_cross_->visible_ = false; -// if (UserInterface::manager().shiftModifier()) { -// overlay_position_cross_->visible_ = true; -// overlay_position_cross_->translation_.x = s->stored_status_->translation_.x; -// overlay_position_cross_->translation_.y = s->stored_status_->translation_.y; -// overlay_position_cross_->update(0); - -// glm::vec3 dif = s->stored_status_->translation_ - sourceNode->translation_; -// if (ABS(dif.x) > ABS(dif.y) ) { -// sourceNode->translation_.y = s->stored_status_->translation_.y; -// ret.type = Cursor_ResizeEW; -// } else { -// sourceNode->translation_.x = s->stored_status_->translation_.x; -// ret.type = Cursor_ResizeNS; -// } -// } + sourceNode->translation_.y = ROUND(sourceNode->translation_.y, 10.f); + // Show grid overlay for POSITION + overlay_position_cross_->visible_ = true; + overlay_position_cross_->translation_.x = sourceNode->translation_.x; + overlay_position_cross_->translation_.y = sourceNode->translation_.y; + overlay_position_cross_->update(0); } // Show center overlay for POSITION overlay_position_->visible_ = true; diff --git a/TextureView.cpp b/TextureView.cpp index 82dc35b..b1993a9 100644 --- a/TextureView.cpp +++ b/TextureView.cpp @@ -121,16 +121,16 @@ TextureView::TextureView() : View(TEXTURE), edit_source_(nullptr), need_edit_upd scene.fg()->attach(overlay_position_); overlay_position_->visible_ = false; // cross to show the axis for POSITION - overlay_position_cross_ = new Symbol(Symbol::CROSS); + overlay_position_cross_ = new Symbol(Symbol::GRID); overlay_position_cross_->color = glm::vec4( COLOR_APPEARANCE_SOURCE, 1.f ); - overlay_position_cross_->rotation_ = glm::vec3(0.f, 0.f, M_PI_4); - overlay_position_cross_->scale_ = glm::vec3(0.3f, 0.3f, 1.f); + overlay_position_cross_->scale_ = glm::vec3(0.5f, 0.5f, 1.f); scene.fg()->attach(overlay_position_cross_); overlay_position_cross_->visible_ = false; // 'grid' : tic marks every 0.1 step for SCALING // with dark background Group *g = new Group; Symbol *s = new Symbol(Symbol::GRID); + s->scale_ = glm::vec3(1.655f, 1.655f, 1.f); s->color = glm::vec4( COLOR_APPEARANCE_SOURCE, 1.f ); g->attach(s); s = new Symbol(Symbol::SQUARE_POINT); @@ -1210,24 +1210,12 @@ View::Cursor TextureView::grab (Source *s, glm::vec2 from, glm::vec2 to, std::pa // discretized translation with ALT if (UserInterface::manager().altModifier()) { sourceNode->translation_.x = ROUND(sourceNode->translation_.x, 10.f); - sourceNode->translation_.y = ROUND(sourceNode->translation_.y, 10.f); - // + SHIFT: single axis movement - overlay_position_cross_->visible_ = false; - if (UserInterface::manager().shiftModifier()) { - overlay_position_cross_->visible_ = true; - overlay_position_cross_->translation_.x = s->stored_status_->translation_.x; - overlay_position_cross_->translation_.y = s->stored_status_->translation_.y; - overlay_position_cross_->update(0); - - glm::vec3 dif = s->stored_status_->translation_ - sourceNode->translation_; - if (ABS(dif.x) > ABS(dif.y) ) { - sourceNode->translation_.y = s->stored_status_->translation_.y; - ret.type = Cursor_ResizeEW; - } else { - sourceNode->translation_.x = s->stored_status_->translation_.x; - ret.type = Cursor_ResizeNS; - } - } + sourceNode->translation_.y = ROUND(sourceNode->translation_.y, 10.f); + // Show grid overlay for POSITION + overlay_position_cross_->visible_ = true; + overlay_position_cross_->translation_.x = sourceNode->translation_.x; + overlay_position_cross_->translation_.y = sourceNode->translation_.y; + overlay_position_cross_->update(0); } // Show center overlay for POSITION overlay_position_->visible_ = true; diff --git a/rsc/mesh/icon_grid.ply b/rsc/mesh/icon_grid.ply index 49a9b7d..4abc206 100644 --- a/rsc/mesh/icon_grid.ply +++ b/rsc/mesh/icon_grid.ply @@ -1,7 +1,7 @@ ply format ascii 1.0 -comment Created by Blender 2.90.0 - www.blender.org -element vertex 48 +comment Created by Blender 2.92.0 - www.blender.org +element vertex 100 property float x property float y property float z @@ -9,57 +9,109 @@ property uchar red property uchar green property uchar blue property uchar alpha -element face 24 +element face 50 property list uchar uint vertex_indices end_header --0.009185 0.712606 0.000000 255 255 255 255 -0.009185 0.611799 0.000000 255 255 255 255 -0.009185 0.712606 0.000000 255 255 255 255 --0.009185 0.611799 0.000000 255 255 255 255 -0.190815 0.712606 0.000000 255 255 255 255 -0.209185 0.611800 0.000000 255 255 255 255 -0.209185 0.712606 0.000000 255 255 255 255 -0.190815 0.611800 0.000000 255 255 255 255 -0.390815 0.712606 0.000000 255 255 255 255 -0.409185 0.611800 0.000000 255 255 255 255 -0.409185 0.712606 0.000000 255 255 255 255 -0.390815 0.611800 0.000000 255 255 255 255 --0.409185 0.712606 0.000000 255 255 255 255 --0.390815 0.611799 0.000000 255 255 255 255 --0.390815 0.712606 0.000000 255 255 255 255 --0.409185 0.611799 0.000000 255 255 255 255 --0.209185 0.712606 0.000000 255 255 255 255 --0.190815 0.611799 0.000000 255 255 255 255 --0.190815 0.712606 0.000000 255 255 255 255 --0.209185 0.611799 0.000000 255 255 255 255 -0.714442 0.007350 0.000000 255 255 255 255 -0.613635 -0.011021 0.000000 255 255 255 255 -0.714442 -0.011021 0.000000 255 255 255 255 -0.613635 0.007350 0.000000 255 255 255 255 -0.714442 -0.192650 0.000000 255 255 255 255 -0.613635 -0.211021 0.000000 255 255 255 255 -0.714442 -0.211021 0.000000 255 255 255 255 -0.613635 -0.192650 0.000000 255 255 255 255 -0.714442 -0.392650 0.000000 255 255 255 255 -0.613635 -0.411021 0.000000 255 255 255 255 -0.714442 -0.411021 0.000000 255 255 255 255 -0.613635 -0.392650 0.000000 255 255 255 255 -0.714441 0.407350 0.000000 255 255 255 255 -0.613635 0.388979 0.000000 255 255 255 255 -0.714441 0.388979 0.000000 255 255 255 255 -0.613635 0.407350 0.000000 255 255 255 255 -0.714442 0.207350 0.000000 255 255 255 255 -0.613635 0.188979 0.000000 255 255 255 255 -0.714442 0.188979 0.000000 255 255 255 255 -0.613635 0.207350 0.000000 255 255 255 255 -0.714441 0.607350 0.000000 255 255 255 255 -0.613635 0.588979 0.000000 255 255 255 255 -0.714441 0.588979 0.000000 255 255 255 255 -0.613635 0.607350 0.000000 255 255 255 255 -0.590815 0.712606 0.000000 255 255 255 255 -0.609185 0.611800 0.000000 255 255 255 255 -0.609185 0.712606 0.000000 255 255 255 255 -0.590815 0.611800 0.000000 255 255 255 255 +-0.404489 -0.395553 0.000000 255 255 255 255 +-0.395511 -0.404447 0.000000 255 255 255 255 +-0.395511 -0.395553 0.000000 255 255 255 255 +-0.404489 -0.404447 0.000000 255 255 255 255 +-0.204489 -0.395553 0.000000 255 255 255 255 +-0.195511 -0.404447 0.000000 255 255 255 255 +-0.195511 -0.395553 0.000000 255 255 255 255 +-0.204489 -0.404447 0.000000 255 255 255 255 +-0.004489 -0.395553 0.000000 255 255 255 255 +0.004489 -0.404447 0.000000 255 255 255 255 +0.004489 -0.395553 0.000000 255 255 255 255 +-0.004489 -0.404447 0.000000 255 255 255 255 +0.195511 -0.395553 0.000000 255 255 255 255 +0.204489 -0.404447 0.000000 255 255 255 255 +0.204489 -0.395553 0.000000 255 255 255 255 +0.195511 -0.404447 0.000000 255 255 255 255 +-0.404489 -0.195553 0.000000 255 255 255 255 +-0.395511 -0.204447 0.000000 255 255 255 255 +-0.395511 -0.195553 0.000000 255 255 255 255 +-0.404489 -0.204447 0.000000 255 255 255 255 +-0.204489 -0.195553 0.000000 255 255 255 255 +-0.195511 -0.204447 0.000000 255 255 255 255 +-0.195511 -0.195553 0.000000 255 255 255 255 +-0.204489 -0.204447 0.000000 255 255 255 255 +-0.004489 -0.195553 0.000000 255 255 255 255 +0.004489 -0.204447 0.000000 255 255 255 255 +0.004489 -0.195553 0.000000 255 255 255 255 +-0.004489 -0.204447 0.000000 255 255 255 255 +0.195511 -0.195553 0.000000 255 255 255 255 +0.204489 -0.204447 0.000000 255 255 255 255 +0.204489 -0.195553 0.000000 255 255 255 255 +0.195511 -0.204447 0.000000 255 255 255 255 +-0.404489 0.004447 0.000000 255 255 255 255 +-0.395511 -0.004447 0.000000 255 255 255 255 +-0.395511 0.004447 0.000000 255 255 255 255 +-0.404489 -0.004447 0.000000 255 255 255 255 +-0.204489 0.004447 0.000000 255 255 255 255 +-0.195511 -0.004447 0.000000 255 255 255 255 +-0.195511 0.004447 0.000000 255 255 255 255 +-0.204489 -0.004447 0.000000 255 255 255 255 +-0.004489 0.004447 0.000000 255 255 255 255 +0.004489 -0.004447 0.000000 255 255 255 255 +0.004489 0.004447 0.000000 255 255 255 255 +-0.004489 -0.004447 0.000000 255 255 255 255 +0.195511 0.004447 0.000000 255 255 255 255 +0.204489 -0.004447 0.000000 255 255 255 255 +0.204489 0.004447 0.000000 255 255 255 255 +0.195511 -0.004447 0.000000 255 255 255 255 +-0.404489 0.204447 0.000000 255 255 255 255 +-0.395511 0.195553 0.000000 255 255 255 255 +-0.395511 0.204447 0.000000 255 255 255 255 +-0.404489 0.195553 0.000000 255 255 255 255 +-0.204489 0.204447 0.000000 255 255 255 255 +-0.195511 0.195553 0.000000 255 255 255 255 +-0.195511 0.204447 0.000000 255 255 255 255 +-0.204489 0.195553 0.000000 255 255 255 255 +-0.004489 0.204447 0.000000 255 255 255 255 +0.004489 0.195553 0.000000 255 255 255 255 +0.004489 0.204447 0.000000 255 255 255 255 +-0.004489 0.195553 0.000000 255 255 255 255 +0.195511 0.204447 0.000000 255 255 255 255 +0.204489 0.195553 0.000000 255 255 255 255 +0.204489 0.204447 0.000000 255 255 255 255 +0.195511 0.195553 0.000000 255 255 255 255 +-0.404489 0.404447 0.000000 255 255 255 255 +-0.395511 0.395553 0.000000 255 255 255 255 +-0.395511 0.404447 0.000000 255 255 255 255 +-0.404489 0.395553 0.000000 255 255 255 255 +-0.204489 0.404447 0.000000 255 255 255 255 +-0.195511 0.395553 0.000000 255 255 255 255 +-0.195511 0.404447 0.000000 255 255 255 255 +-0.204489 0.395553 0.000000 255 255 255 255 +-0.004489 0.404447 0.000000 255 255 255 255 +0.004489 0.395553 0.000000 255 255 255 255 +0.004489 0.404447 0.000000 255 255 255 255 +-0.004489 0.395553 0.000000 255 255 255 255 +0.195511 0.404447 0.000000 255 255 255 255 +0.204489 0.395553 0.000000 255 255 255 255 +0.204489 0.404447 0.000000 255 255 255 255 +0.195511 0.395553 0.000000 255 255 255 255 +0.395511 -0.395553 0.000000 255 255 255 255 +0.404489 -0.404447 0.000000 255 255 255 255 +0.404489 -0.395553 0.000000 255 255 255 255 +0.395511 -0.404447 0.000000 255 255 255 255 +0.395511 -0.195553 0.000000 255 255 255 255 +0.404489 -0.204447 0.000000 255 255 255 255 +0.404489 -0.195553 0.000000 255 255 255 255 +0.395511 -0.204447 0.000000 255 255 255 255 +0.395511 0.004447 0.000000 255 255 255 255 +0.404489 -0.004447 0.000000 255 255 255 255 +0.404489 0.004447 0.000000 255 255 255 255 +0.395511 -0.004447 0.000000 255 255 255 255 +0.395511 0.204447 0.000000 255 255 255 255 +0.404489 0.195553 0.000000 255 255 255 255 +0.404489 0.204447 0.000000 255 255 255 255 +0.395511 0.195553 0.000000 255 255 255 255 +0.395511 0.404447 0.000000 255 255 255 255 +0.404489 0.395553 0.000000 255 255 255 255 +0.404489 0.404447 0.000000 255 255 255 255 +0.395511 0.395553 0.000000 255 255 255 255 3 0 1 2 3 0 3 1 3 4 5 6 @@ -84,3 +136,29 @@ end_header 3 40 43 41 3 44 45 46 3 44 47 45 +3 48 49 50 +3 48 51 49 +3 52 53 54 +3 52 55 53 +3 56 57 58 +3 56 59 57 +3 60 61 62 +3 60 63 61 +3 64 65 66 +3 64 67 65 +3 68 69 70 +3 68 71 69 +3 72 73 74 +3 72 75 73 +3 76 77 78 +3 76 79 77 +3 80 81 82 +3 80 83 81 +3 84 85 86 +3 84 87 85 +3 88 89 90 +3 88 91 89 +3 92 93 94 +3 92 95 93 +3 96 97 98 +3 96 99 97