]> Creatis software - clitk.git/commitdiff
class name and file name should always match
authorschaerer <schaerer>
Mon, 8 Mar 2010 07:49:50 +0000 (07:49 +0000)
committerschaerer <schaerer>
Mon, 8 Mar 2010 07:49:50 +0000 (07:49 +0000)
vv/vvSlicerManager.cxx
vv/vvSlicerManagerCommand.cxx
vv/vvSlicerManagerCommand.h

index 4aa48cf562d8d92e36ec2aacbce888062bb0a6dd..74a059863314c0634c9c0d42f413e922ee1a1b05 100644 (file)
@@ -338,8 +338,10 @@ void vvSlicerManager::SetSlicerWindow(int i, vtkRenderWindow* RW)
 
 void vvSlicerManager::SetInteractorStyleNavigator(int i, vtkInteractorStyle* style)
 {
-    vvSlicerManagerCallback *smc = vvSlicerManagerCallback::New();
+    vvSlicerManagerCommand *smc = vvSlicerManagerCommand::New();
+    std::cerr << smc << ":" << i << "  " << this << endl;
     smc->SM = this;
+    smc->SetSlicerNumber(i);
     mSlicers[i]->GetRenderWindow()->GetInteractor()->SetInteractorStyle(style);
 
     mSlicers[i]->GetRenderWindow()->GetInteractor()->
index 6e3298b792cff082320e4440123b9bbfed087cd4..d9a1240f6d5dd563c8f24a27800d393235f0b13c 100644 (file)
 #include <cmath>
 
 //------------------------------------------------------------------------------
-vvSlicerManagerCallback::vvSlicerManagerCallback()
+vvSlicerManagerCommand::vvSlicerManagerCommand()
 {
   mStartSlicer = -1;
+  mSlicerNumber=-1;
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 //return the num of the current slicer if visible (-1 else)
-int vvSlicerManagerCallback::FindSlicerNumber(vtkRenderWindow* renwin)
+int vvSlicerManagerCommand::FindSlicerNumber(vtkRenderWindow* renwin)
 {
-  int result=-1;
-  for (int i = 0; i < SM->NumberOfSlicers(); i++)
-    {
-      if (SM->GetSlicer(i)->GetRenderWindow() == renwin
-         && SM->GetSlicer(i)->GetRenderer()->GetDraw())
-        {
-         //            DD(i);
-         result=i;
-        }
-    }
-  return result;
+    if (renwin != SM->GetSlicer(mSlicerNumber)->GetRenderWindow() ||
+            !SM->GetSlicer(mSlicerNumber)->GetRenderer()->GetDraw())
+        return -1;
+    else return mSlicerNumber;
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvSlicerManagerCallback::Execute(vtkObject *caller,
+void vvSlicerManagerCommand::Execute(vtkObject *caller,
                                      unsigned long event,
                                      void *vtkNotUsed(callData))
 {
+  std::cerr << this << ":" << mSlicerNumber << endl;
   //KeyPress event
   vvInteractorStyleNavigator *isi =
     dynamic_cast<vvInteractorStyleNavigator *>(caller);
@@ -260,6 +255,7 @@ void vvSlicerManagerCallback::Execute(vtkObject *caller,
 
              if (KeyPress == "F1")
                 {
+    std::cerr << this << ":" << this->SM->GetId() << "\t" << VisibleInWindow << endl;
                  this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Sagital\n<slice>");
                  this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(0);
                  this->SM->UpdateSliceRange(VisibleInWindow);
@@ -427,7 +423,7 @@ void vvSlicerManagerCallback::Execute(vtkObject *caller,
 
 
 //------------------------------------------------------------------------------
-void vvSlicerManagerCallback::Dolly(double factor, vtkRenderWindowInteractor *interactor)
+void vvSlicerManagerCommand::Dolly(double factor, vtkRenderWindowInteractor *interactor)
 {
   int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
   vtkRenderer* renderer;
@@ -505,7 +501,7 @@ void vvSlicerManagerCallback::Dolly(double factor, vtkRenderWindowInteractor *in
   //interactor->Render();
 }
 
-void vvSlicerManagerCallback::FlyToPosition(vtkRenderWindowInteractor *interactor,vvSlicer* slicer)
+void vvSlicerManagerCommand::FlyToPosition(vtkRenderWindowInteractor *interactor,vvSlicer* slicer)
 {
   double flyFrom[3], flyTo[3];
   double d[3], focalPt[3], position[3], positionFrom[3];
index e2c72d5d23cbde9ab5bdad8c5b1a18a7f218188d..2152b9b9b295aca8671ee744e477fa38bc550fed 100644 (file)
@@ -39,11 +39,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <string>
 #include <sstream>
 
-class vvSlicerManagerCallback : public vtkCommand
+class vvSlicerManagerCommand : public vtkCommand
 {
 public:
-    static vvSlicerManagerCallback *New() {
-        return new vvSlicerManagerCallback;
+    static vvSlicerManagerCommand *New() {
+        return new vvSlicerManagerCommand;
     }
 
     void Execute(vtkObject *caller,
@@ -53,10 +53,11 @@ public:
     vvSlicerManager *SM;
     void Dolly(double factor, vtkRenderWindowInteractor *interactor);
     void FlyToPosition(vtkRenderWindowInteractor *interactor, vvSlicer* slicer);
+    void SetSlicerNumber(int slicer) {mSlicerNumber=slicer;}
 
 protected :
-    vvSlicerManagerCallback();
-    ~vvSlicerManagerCallback() {}
+    vvSlicerManagerCommand();
+    ~vvSlicerManagerCommand() {}
 
 private:
 
@@ -66,6 +67,8 @@ private:
     double InitialLevel;
     int mStartSlicer;
     bool newLandmark;
+    ///The slicer this callback commands
+    int mSlicerNumber;
 };
 
 #endif