added gizmo but not yet working

This commit is contained in:
AndreaRigoni
2026-03-08 10:21:38 +00:00
parent 2548582036
commit 1374821344
5 changed files with 491 additions and 11 deletions

111
src/Vtk/vtkHandlerWidget.h Normal file
View File

@@ -0,0 +1,111 @@
/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef U_VTKHANDLERWIDGET_H
#define U_VTKHANDLERWIDGET_H
#include "Math/Dense.h"
#include "uLibVtkInterface.h"
#include <vtk3DWidget.h>
#include <vtkSmartPointer.h>
// Forward declarations of VTK classes in global namespace
class vtkActor;
class vtkCallbackCommand;
class vtkPropPicker;
class vtkTransform;
class vtkObject;
class vtkRenderWindowInteractor;
namespace uLib {
namespace Vtk {
/**
* @class vtkHandlerWidget
* @brief A Blender-like transform gizmo for move, rotate, and scale.
*/
class vtkHandlerWidget : public ::vtk3DWidget {
public:
static vtkHandlerWidget *New();
vtkTypeMacro(vtkHandlerWidget, ::vtk3DWidget);
vtkHandlerWidget();
virtual ~vtkHandlerWidget();
virtual void SetEnabled(int enabling) override;
static void ProcessEvents(::vtkObject *caller, unsigned long event,
void *clientdata, void *calldata);
void OnLeftButtonDown();
void OnLeftButtonUp();
void OnMouseMove();
enum InteractionState {
IDLE = 0,
TRANS_X,
TRANS_Y,
TRANS_Z,
ROT_X,
ROT_Y,
ROT_Z,
SCALE_X,
SCALE_Y,
SCALE_Z
};
using ::vtk3DWidget::PlaceWidget;
virtual void PlaceWidget(double bounds[6]) override;
virtual void PlaceWidget() override;
// Transform handling //
void SetTransform(::vtkTransform *t);
void GetTransform(::vtkTransform *t);
protected:
void CreateGizmos();
void UpdateGizmoPosition();
int Interaction;
// Visual components //
vtkSmartPointer<::vtkActor> m_AxesX, m_AxesY, m_AxesZ; // Arrows
vtkSmartPointer<::vtkActor> m_RotX, m_RotY, m_RotZ; // Rings
vtkSmartPointer<::vtkActor> m_ScaleX, m_ScaleY, m_ScaleZ; // Cubes
vtkSmartPointer<::vtkPropPicker> m_Picker;
double StartEventPosition[2];
vtkSmartPointer<::vtkTransform> m_InitialTransform;
private:
vtkHandlerWidget(const vtkHandlerWidget &) = delete;
void operator=(const vtkHandlerWidget &) = delete;
};
} // namespace Vtk
} // namespace uLib
#endif // U_VTKHANDLERWIDGET_H