From: Jose Luis Guzman Date: Thu, 29 Oct 2015 10:35:32 +0000 (+0100) Subject: widgets update X-Git-Tag: v0.1~314^2~1 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d56baa341853f2a8ffb8a6436619b54f146200ee;p=cpPlugins.git widgets update --- diff --git a/appli/examples/example_SphereWidget.cxx b/appli/examples/example_SphereWidget.cxx index ac0d27c..8de844a 100644 --- a/appli/examples/example_SphereWidget.cxx +++ b/appli/examples/example_SphereWidget.cxx @@ -105,11 +105,11 @@ int main(int argc, char* argv[]) vtkSmartPointer sphereWidget = vtkSmartPointer::New(); sphereWidget->SetInteractor(interactor); - sphereWidget->CreateDefaultRepresentation(); +// sphereWidget->CreateDefaultRepresentation(); - vtkSphereRepresentation* sphereRepresentation = + /* vtkSphereRepresentation* sphereRepresentation = vtkSphereRepresentation::SafeDownCast(sphereWidget->GetRepresentation()); - sphereRepresentation->HandleVisibilityOn(); + sphereRepresentation->HandleVisibilityOn();*/ // Begin interaction renderer->ResetCamera(); diff --git a/lib/cpExtensions/Interaction/SphereWidget.cxx b/lib/cpExtensions/Interaction/SphereWidget.cxx index 7c326e3..07d778f 100644 --- a/lib/cpExtensions/Interaction/SphereWidget.cxx +++ b/lib/cpExtensions/Interaction/SphereWidget.cxx @@ -8,9 +8,8 @@ #include #include #include -#include #include - +#include // ------------------------------------------------------------------------- cpExtensions::Interaction::SphereWidget:: @@ -39,19 +38,19 @@ cpExtensions::Interaction::SphereWidget:: SphereWidget() : Superclass() { - vtkSmartPointer sphereRepresentation = - vtkSphereRepresentation::SafeDownCast(this->GetRepresentation()); + /*vtkSmartPointer 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(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 sphere = vtkSmartPointer::New(); + + + self->InvokeEvent(vtkCommand::ModifiedEvent, NULL); + self->Modified(); + self->GetInteractor()->Render(); + self->ReleaseFocus(); } diff --git a/lib/cpExtensions/Interaction/SphereWidget.h b/lib/cpExtensions/Interaction/SphereWidget.h index dd6a499..11ce916 100644 --- a/lib/cpExtensions/Interaction/SphereWidget.h +++ b/lib/cpExtensions/Interaction/SphereWidget.h @@ -3,7 +3,7 @@ #include #include -#include +#include 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; diff --git a/lib/cpPlugins/Interface/BaseMPRWidget.cxx b/lib/cpPlugins/Interface/BaseMPRWidget.cxx index 88e3b89..7caa4e0 100644 --- a/lib/cpPlugins/Interface/BaseMPRWidget.cxx +++ b/lib/cpPlugins/Interface/BaseMPRWidget.cxx @@ -125,6 +125,7 @@ ShowMesh( const double& r, const double& g, const double& b ) { + return false; } // -------------------------------------------------------------------------