#include <vtkWidgetRepresentation.h>
#include <vtkActor.h>
#include <vtkSphereRepresentation.h>
-#include <vtkSphereWidget2.h>
#include <vtkSmartPointer.h>
-
+#include <vtkSphere.h>
// -------------------------------------------------------------------------
cpExtensions::Interaction::SphereWidget::
SphereWidget()
: Superclass()
{
- vtkSmartPointer<vtkSphereRepresentation> sphereRepresentation =
- vtkSphereRepresentation::SafeDownCast(this->GetRepresentation());
+ /*vtkSmartPointer<vtkself> self =
+ vtkself::SafeDownCast(this->GetRepresentation());*/
- //sphereRepresentation->SetHandleSize(0);
- sphereRepresentation->SetRadialLine(2);
- sphereRepresentation->SetRadius(7);
+ //self->SetHandleSize(0);
+ //self->SetRadialLine(2);
+ this->SetRadius(7);
- sphereRepresentation->SetPhiResolution(10);
- sphereRepresentation->SetThetaResolution(20);
+ this->SetPhiResolution(10);
+ this->SetThetaResolution(20);
- //sphereRepresentation->HandleVisibilityOff();
- //sphereRepresentation->SetHandleText(0);
- sphereRepresentation->SetRepresentationToWireframe();
+ //self->HandleVisibilityOff();
+ //self->SetHandleText(0);
+ this->SetRepresentationToWireframe();
// Remove default translations
/* vtkWidgetEventTranslator* t = this->GetEventTranslator();
SphereWidget* self = reinterpret_cast<SphereWidget*>(data);
double handlePosition[3];
- vtkSphereRepresentation* sphereRepresentation =
- vtkSphereRepresentation::SafeDownCast(self->GetRepresentation());
-
-
+ /* vtkself* self =
+ vtkself::SafeDownCast(self->GetRepresentation());
+ */
+ auto center = self->GetCenter();
+ auto center2 = self->GetCenter();
+ auto radius = self->GetRadius();
- auto center = sphereRepresentation->GetCenter();
self->Superclass::StartInteraction();
switch (key)
{
case 122: // Z & z
case 90:
- sphereRepresentation->SetRadius(sphereRepresentation->GetRadius() + 0.1);
+ radius += 0.1;
+ //self->SetRadius(radius);
break;
case 88: // X & x
case 120:
- sphereRepresentation->SetRadius(sphereRepresentation->GetRadius() - 0.1);
+ radius -= 0.1;
+ //self->SetRadius(radius);
break;
case 119: // W & w
case 87:
center[0] += 1;
- sphereRepresentation->SetCenter(center);
+ self->Translate(center, center2);
break;
case 83: // S & s
case 115:
center[0] -= 1;
- sphereRepresentation->SetCenter(center);
+ self->Translate(center, center2);
break;
case 65: // A & a
case 97:
center[1] += 1;
- sphereRepresentation->SetCenter(center);
+ self->SetCenter(center);
break;
case 100: // D & d
case 68:
center[1] -= 1;
- sphereRepresentation->SetCenter(center);
+ self->SetCenter(center);
break;
case 81: // Q & q
case 113:
center[2] += 1;
- sphereRepresentation->SetCenter(center);
+ self->SetCenter(center);
break;
case 69: // E & e
case 101:
center[2] -= 1;
- sphereRepresentation->SetCenter(center);
+ self->SetCenter(center);
break;
default:
break;
}
- self->SetKeyPressActivation(1);
- self->Render();
+
+ self->SetRadius(radius);
+ self->Translate(center, center2);
+
+ vtkSmartPointer<vtkSphere> sphere = vtkSmartPointer<vtkSphere>::New();
+
+
+ self->InvokeEvent(vtkCommand::ModifiedEvent, NULL);
+ self->Modified();
+ self->GetInteractor()->Render();
+ self->ReleaseFocus();
}
#include <cpExtensions/cpExtensions_Export.h>
#include <cpExtensions/Interaction/BaseInteractorStyle.h>
-#include <vtkSphereWidget2.h>
+#include <vtkSphereWidget.h>
namespace cpExtensions
{
/**
*/
class cpExtensions_EXPORT SphereWidget
- : public vtkSphereWidget2
+ : public vtkSphereWidget
{
public:
typedef SphereWidget Self;
- vtkTypeMacro( SphereWidget, vtkSphereWidget2 );
+ vtkTypeMacro( SphereWidget, vtkSphereWidget );
typedef cpExtensions::Interaction::BaseInteractorStyle TBaseStyle;
typedef TBaseStyle::TMouseCommand TMouseCommand;