]> Creatis software - cpPlugins.git/commitdiff
widgets update
authorJose Luis Guzman <cycopepe@gmail.com>
Thu, 29 Oct 2015 10:35:32 +0000 (11:35 +0100)
committerJose Luis Guzman <cycopepe@gmail.com>
Thu, 29 Oct 2015 10:35:32 +0000 (11:35 +0100)
appli/examples/example_SphereWidget.cxx
lib/cpExtensions/Interaction/SphereWidget.cxx
lib/cpExtensions/Interaction/SphereWidget.h
lib/cpPlugins/Interface/BaseMPRWidget.cxx

index ac0d27c81b553b82ba70e548e2715c6d0af97ea8..8de844a8f49b3660e469529bbaa3d913f7cead5a 100644 (file)
@@ -105,11 +105,11 @@ int main(int argc, char* argv[])
   vtkSmartPointer<TSphereWidget> sphereWidget =
     vtkSmartPointer<TSphereWidget>::New();
   sphereWidget->SetInteractor(interactor);
-  sphereWidget->CreateDefaultRepresentation();
+//  sphereWidget->CreateDefaultRepresentation();
 
-  vtkSphereRepresentation* sphereRepresentation =
/* vtkSphereRepresentation* sphereRepresentation =
     vtkSphereRepresentation::SafeDownCast(sphereWidget->GetRepresentation());
-  sphereRepresentation->HandleVisibilityOn();
+  sphereRepresentation->HandleVisibilityOn();*/
 
   // Begin interaction
   renderer->ResetCamera();
index 7c326e3723e6bb4fc097a905b11e82ab55bdeac1..07d778f84041a39e58e8308ff12dcf697c38b9aa 100644 (file)
@@ -8,9 +8,8 @@
 #include <vtkWidgetRepresentation.h>
 #include <vtkActor.h>
 #include <vtkSphereRepresentation.h>
-#include <vtkSphereWidget2.h>
 #include <vtkSmartPointer.h>
-
+#include <vtkSphere.h>
 
 // -------------------------------------------------------------------------
 cpExtensions::Interaction::SphereWidget::
@@ -39,19 +38,19 @@ 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();
@@ -110,60 +109,72 @@ void cpExtensions::Interaction::SphereWidget::_KeyPress(void* data, const char&
   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();
 }
 
 
index dd6a499a2e2551d0505fc62dbe736929a655e77c..11ce916c814bc236c29c3345b67b0fe8b0ff4e04 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <cpExtensions/cpExtensions_Export.h>
 #include <cpExtensions/Interaction/BaseInteractorStyle.h>
-#include <vtkSphereWidget2.h>
+#include <vtkSphereWidget.h>
 
 namespace cpExtensions
 {
@@ -12,11 +12,11 @@ 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;
index 88e3b894ecb483567e2a5bfe7fb1f07dafdaaee3..7caa4e0d11adc2d197259571f10fd2beb6c7ea99 100644 (file)
@@ -125,6 +125,7 @@ ShowMesh(
   const double& r, const double& g, const double& b
   )
 {
+  return false;
 }
 
 // -------------------------------------------------------------------------