From b46fafcd2915faba65f54d7a4f41fca592d3121f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20M=C3=B6bius?= <moebius@cs.rwth-aachen.de>
Date: Thu, 27 Aug 2020 15:20:29 +0200
Subject: [PATCH] Added Picking Mode for Plane resize

---
 PlanePlugin.cc | 78 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 77 insertions(+), 1 deletion(-)

diff --git a/PlanePlugin.cc b/PlanePlugin.cc
index fb4cd93..a964b10 100644
--- a/PlanePlugin.cc
+++ b/PlanePlugin.cc
@@ -8,6 +8,7 @@
 #include <ACG/Scenegraph/LineNode.hh>
 
 const char *PLANE = "CreatePlaneNode";
+const char *PLANE_RESIZE = "PlaneResize";
 
 //------------------------------------------------------------------------------
 
@@ -40,6 +41,8 @@ void PlanePlugin::pluginsInitialized()
 
   emit addPickMode( PLANE );
 
+  emit addPickMode( PLANE_RESIZE );
+
   createPlane_ = new QtPlaneSelect( PluginFunctions::viewerProperties().glState() );
   connect( createPlane_, SIGNAL( signalTriggerCut( ) ), this, SLOT( slotCreatePlaneTriggered() ) );
   connect( createPlane_, SIGNAL( updateViewProxy( ) ), this, SIGNAL( updateView() ) );
@@ -96,7 +99,80 @@ void PlanePlugin::slotKeyReleaseEvent( QKeyEvent* _event){
 void PlanePlugin::slotMouseEvent( QMouseEvent* _event ) {
   
     if( PluginFunctions::pickMode() == PLANE )
-    createPlane_->slotMouseEvent( _event );
+        createPlane_->slotMouseEvent( _event );
+    if( PluginFunctions::pickMode() == PLANE_RESIZE ) {
+        switch( _event->type() )
+        {
+        case QEvent::MouseButtonPress:
+        {
+            ACG::Vec3d sourcePoint3D;
+            size_t     node_idx, target_idx;
+            if (PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_ANYTHING,
+                                                  _event->pos(),
+                                                  node_idx,
+                                                  target_idx,
+                                                  &sourcePoint3D))
+            {
+                BaseObjectData* obj = nullptr;
+                if (PluginFunctions::getPickedObject(node_idx, obj)) {
+                  // is picked object Plane?
+                  PlaneObject* curPlane = PluginFunctions::planeObject(obj);
+
+                  if (curPlane) {
+
+
+                      // Hit the plane
+                      if (target_idx == 0) {
+
+                      }
+
+                      // Hit the plane 0 corner
+                      if (target_idx == 1) {
+                        curPlane->plane().setSize(1.0,0.5);
+                      }
+
+                      // Hit the plane x corner
+                      if (target_idx == 2) {
+
+                      }
+
+                      // Hit the plane xy corner
+                      if (target_idx == 3) {
+
+                      }
+
+                      // Hit the plane y
+                      if (target_idx == 4) {
+
+                      }
+
+                      std::cerr << "Picked a plane! and id" << target_idx << std::endl;
+                  }
+                }
+
+            }
+
+            std::cerr << "Mouse_Down"  << std::endl;
+            break;
+        }
+
+        case QEvent::MouseMove:
+        {
+            std::cerr << "Mouse_Move"  << std::endl;
+            break;
+        }
+        case QEvent::MouseButtonRelease:
+        {
+            std::cerr << "Mouse_Release"  << std::endl;
+            break;
+        }
+        default:
+            break;
+        }
+
+    }
+
+
 }
 
 /*******************************************************************************
-- 
GitLab