]> Creatis software - clitk.git/blob - vv/vvSlicerManagerCommand.cxx
Change key for going to coordinate system origin. Now CTRL+g
[clitk.git] / vv / vvSlicerManagerCommand.cxx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
18 #include "vvSlicerManagerCommand.h"
19 #include "vvSlicerManager.h"
20
21 #include <vtkTextProperty.h>
22 #include <vtkRenderer.h>
23 #include <vtkImageActor.h>
24 #include <vtkRenderWindowInteractor.h>
25 #include <vtkPropPicker.h>
26 #include <vtkCamera.h>
27 #include <vtkImageMapToWindowLevelColors.h>
28 #include <vtkLookupTable.h>
29 #include <vtkMath.h>
30 #include <vtkAbstractPropPicker.h>
31 #include <vtkAssemblyPath.h>
32 #include <vtkCornerAnnotation.h>
33 #include <vtkRenderWindow.h>
34 #include <vvImage.h>
35 #include <vtkImageReslice.h>
36 #include "vvSlicer.h"
37 #include "vvInteractorStyleNavigator.h"
38 #include "vtkTransform.h"
39
40 #include <cmath>
41
42 //------------------------------------------------------------------------------
43 vvSlicerManagerCommand::vvSlicerManagerCommand()
44 {
45   mStartSlicer = -1;
46   mSlicerNumber=-1;
47 }
48 //------------------------------------------------------------------------------
49
50
51 //------------------------------------------------------------------------------
52 //return the num of the current slicer if visible (-1 else)
53 int vvSlicerManagerCommand::FindSlicerNumber(vtkRenderWindow* renwin)
54 {
55   int rvalue;
56   if (renwin != SM->GetSlicer(mSlicerNumber)->GetRenderWindow() ||
57       !SM->GetSlicer(mSlicerNumber)->GetRenderer()->GetDraw())
58     rvalue = -1;
59   else rvalue = mSlicerNumber;
60   //std::cerr << this << ":" << mSlicerNumber << ": " << rvalue << endl;
61   return rvalue;
62 }
63 //------------------------------------------------------------------------------
64
65
66 //------------------------------------------------------------------------------
67 void vvSlicerManagerCommand::Execute(vtkObject *caller,
68                                      unsigned long event,
69                                      void *vtkNotUsed(callData))
70 {
71   //KeyPress event
72   vvInteractorStyleNavigator *isi =
73     dynamic_cast<vvInteractorStyleNavigator *>(caller);
74   if (isi) {
75     double x = isi->GetInteractor()->GetEventPosition()[0];
76     double y = isi->GetInteractor()->GetEventPosition()[1];
77     double z;
78
79     int VisibleInWindow = this->FindSlicerNumber(isi->GetInteractor()->GetRenderWindow());
80     vtkRenderer* renderer=NULL;
81     if (VisibleInWindow>-1)
82       renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
83     newLandmark = false;
84
85
86
87     if (event == vtkCommand::StartPickEvent && VisibleInWindow == -1) {
88       for (int i = 0; i < this->SM->GetNumberOfSlicers(); i++) {
89         if (this->SM->GetSlicer(i)->GetCursorVisibility() && !this->SM->IsLinked()) {
90           this->SM->GetSlicer(i)->SetCursorVisibility(0);
91           this->SM->GetSlicer(i)->SetCornerAnnotationVisibility(0);
92           this->SM->GetSlicer(i)->Render();
93         }
94       }
95     }
96     if ( VisibleInWindow > -1 ) {
97       if (event == vtkCommand::KeyPressEvent) {
98         std::string KeyPress = isi->GetInteractor()->GetKeySym();
99         bool bCtrlKey = isi->GetInteractor()->GetControlKey();
100         if (KeyPress == "Tab") {
101           if(isi->GetInteractor()->GetShiftKey())
102             this->SM->PrevImage(VisibleInWindow);
103           else
104             this->SM->NextImage(VisibleInWindow);
105           return;
106         }
107         if (KeyPress == "f" || KeyPress == "F") {
108           FlyToPosition(isi->GetInteractor(),this->SM->GetSlicer(VisibleInWindow));
109           return;
110         }
111         if (KeyPress == "w") {
112           this->SM->SetLocalColorWindowing(VisibleInWindow);
113           return;
114         }
115         if (KeyPress == "0") {
116           this->SM->SetPreset(0);
117           this->SM->UpdateWindowLevel();
118           return;
119         }
120         if (KeyPress == "1") {
121           this->SM->SetPreset(1);
122           this->SM->UpdateWindowLevel();
123           return;
124         }
125         if (KeyPress == "2") {
126           this->SM->SetPreset(2);
127           this->SM->UpdateWindowLevel();
128
129           return;
130         }
131         if (KeyPress == "3") {
132           this->SM->SetPreset(3);
133           this->SM->UpdateWindowLevel();
134           return;
135         }
136         if (KeyPress == "4") {
137           this->SM->SetPreset(4);
138           this->SM->UpdateWindowLevel();
139           return;
140         }
141         if (KeyPress == "5") {
142           this->SM->SetPreset(5);
143           this->SM->UpdateWindowLevel();
144           return;
145         }
146         if (KeyPress == "6") {
147           this->SM->SetColorMap(0);
148           this->SM->UpdateWindowLevel();
149           return;
150         }
151         if (KeyPress == "7") {
152           this->SM->SetColorMap(1);
153           this->SM->UpdateWindowLevel();
154           return;
155         }
156         if (KeyPress == "8") {
157           this->SM->SetColorMap(2);
158           this->SM->UpdateWindowLevel();
159           return;
160         }
161         if (KeyPress == "9") {
162           this->SM->SetColorMap(3);
163           this->SM->UpdateWindowLevel();
164           return;
165         }
166         if (KeyPress == "equal") { //keycodes are in vtkWin32RenderWindowInteractor
167           this->SM->SetPreset(7);
168           //this->SM->SetColorMap(1);
169           this->SM->UpdateWindowLevel();
170           return;
171         }
172         if (KeyPress == "minus") {
173           this->SM->SetColorWindow(-this->SM->GetColorWindow());
174           this->SM->SetColorMap(-1);
175           this->SM->UpdateWindowLevel();
176           return;
177         }
178         if (KeyPress == "c") {
179           this->SM->ToggleContourSuperposition();
180           this->SM->Render();
181           return;
182         }
183         if (KeyPress == "l") {
184           this->SM->ToggleInterpolation();
185           this->SM->Render();
186           return;
187         }
188         if (KeyPress == "h") {
189           std::cout << "KeyPress == \"h\"\n";
190           this->SM->SetCursorAndCornerAnnotationVisibility(0);
191           this->SM->Render();
192           return;
193         }
194         if (KeyPress == "x") {
195           for(int i=0; i<SM->GetNumberOfSlicers(); i++) {
196             SM->RemoveActor("overlay",0);
197             SM->SetColorMap(0);
198             SM->Render();
199           }
200           return;
201         }
202         if (KeyPress == "u") {
203           this->SM->Reload();
204           this->SM->Render();
205           return;
206         }
207         if (KeyPress == "r" || KeyPress=="R") {
208           this->SM->GetSlicer(VisibleInWindow)->ResetCamera();
209           this->SM->GetSlicer(VisibleInWindow)->Render();
210           this->SM->UpdateLinkedNavigation( this->SM->GetSlicer(VisibleInWindow) );
211           return;
212         }
213         if (KeyPress == "g") {
214           if(bCtrlKey)
215             this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(0,0,0,0);
216           else {
217             double* cursorPos = this->SM->GetSlicer(VisibleInWindow)->GetCursorPosition();
218             this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(
219               cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
220           }
221           this->SM->UpdateViews(1,VisibleInWindow);
222           this->SM->UpdateLinked(VisibleInWindow);
223           return;
224         }
225         if (KeyPress == "F5") {
226           this->SM->GetSlicer(VisibleInWindow)->FlipHorizontalView();
227           this->SM->GetSlicer(VisibleInWindow)->Render();
228           return;
229         }
230         if (KeyPress == "F6") {
231           this->SM->GetSlicer(VisibleInWindow)->FlipVerticalView();
232           this->SM->GetSlicer(VisibleInWindow)->Render();
233           return;
234         }
235         if (KeyPress == "Up") {
236           this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
237           this->SM->UpdateSlice(VisibleInWindow);
238         }
239         if (KeyPress == "Down") {
240           this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
241           this->SM->UpdateSlice(VisibleInWindow);
242         }
243         if (KeyPress == "space") {
244           newLandmark = true;
245         }
246         if (KeyPress == "Left")
247           this->SM->SetPreviousTSlice(VisibleInWindow);
248         if (KeyPress == "Right")
249           this->SM->SetNextTSlice(VisibleInWindow);
250
251         if (KeyPress == "F2") {
252           this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Sagital\n<slice>");
253           //this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(0);
254           this->SM->SetSliceOrientation(VisibleInWindow, 0);
255           this->SM->UpdateSliceRange(VisibleInWindow);
256         }
257         if (KeyPress == "F3") {
258           this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Coronal\n<slice>");
259           //this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(1);
260           this->SM->SetSliceOrientation(VisibleInWindow, 1);
261           this->SM->UpdateSliceRange(VisibleInWindow);
262         }
263         if (KeyPress == "F4") {
264           this->SM->GetSlicer(VisibleInWindow)->GetAnnotation()->SetText(2,"Axial\n<slice>");
265           //this->SM->GetSlicer(VisibleInWindow)->SetSliceOrientation(2);
266           this->SM->SetSliceOrientation(VisibleInWindow, 2);
267           this->SM->UpdateSliceRange(VisibleInWindow);
268         }
269
270       }
271
272       //All type of mouse events
273       if (event == vtkCommand::LeaveEvent) {
274         this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
275             -VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
276         this->SM->GetSlicer(VisibleInWindow)->Render();
277         return;
278       }
279
280       //DD(event);
281       // Mouse release HERE
282       if (event == vtkCommand::EndPickEvent) {
283         //            DD(VisibleInWindow);
284         if (VisibleInWindow > -1)
285           this->SM->LeftButtonReleaseEvent(VisibleInWindow);
286         return; // no return !!!! ???
287       }
288
289       if (event == vtkCommand::StartWindowLevelEvent) {
290         mStartSlicer = -1;
291         this->InitialWindow = this->SM->GetColorWindow();
292         this->InitialLevel = this->SM->GetColorLevel();
293
294         if (VisibleInWindow > -1) {
295           mStartSlicer = VisibleInWindow;
296         }
297         return;
298       }
299
300       if (event == vtkCommand::EndWindowLevelEvent) {
301         mStartSlicer = -1;
302       }
303
304       if (event == vtkCommand::EndInteractionEvent) {
305         this->SM->Picked();
306         this->SM->UpdateLinkedNavigation(this->SM->GetSlicer(VisibleInWindow),true);
307         return;
308       }
309     }
310     if (VisibleInWindow > -1) {
311       this->SM->Activated();
312       this->SM->GetSlicer(VisibleInWindow)->SetCornerAnnotationVisibility(1);
313
314       if (event == vtkCommand::MouseWheelForwardEvent && !isi->GetInteractor()->GetControlKey()) {
315         this->SM->Picked();
316         this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()+1);
317         this->SM->UpdateSlice(VisibleInWindow);
318       } else if (event == vtkCommand::MouseWheelForwardEvent && isi->GetInteractor()->GetControlKey()) {
319         double factor = 2;
320         this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
321         Execute(caller, vtkCommand::EndInteractionEvent, NULL);
322       } else if (event == vtkCommand::MouseWheelBackwardEvent && !isi->GetInteractor()->GetControlKey()) {
323         this->SM->Picked();
324         this->SM->GetSlicer(VisibleInWindow)->SetSlice(this->SM->GetSlicer(VisibleInWindow)->GetSlice()-1);
325         this->SM->UpdateSlice(VisibleInWindow);
326       } else if (event == vtkCommand::MouseWheelBackwardEvent && isi->GetInteractor()->GetControlKey()) {
327         double factor = -2;
328         this->Dolly(pow((double)1.1, factor),isi->GetInteractor());
329         Execute(caller, vtkCommand::EndInteractionEvent, NULL);
330       }
331       double xWorld=0;
332       double yWorld=0;
333       double zWorld=0;
334
335       //Move into World Coordinate
336       renderer->DisplayToNormalizedDisplay(x,y);
337       renderer->NormalizedDisplayToViewport(x,y);
338       renderer->ViewportToNormalizedViewport(x,y);
339       renderer->NormalizedViewportToView(x,y,z);
340       renderer->ViewToWorld(x,y,z);
341       switch (this->SM->GetSlicer(VisibleInWindow)->GetSliceOrientation()) {
342       case vtkImageViewer2::SLICE_ORIENTATION_XY:
343         xWorld = x;
344         yWorld = y;
345         zWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
346                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[2] +
347                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[2];
348         break;
349
350       case vtkImageViewer2::SLICE_ORIENTATION_XZ:
351         xWorld = x;
352         yWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
353                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[1] +
354                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[1];
355         zWorld = z;
356         break;
357
358       case vtkImageViewer2::SLICE_ORIENTATION_YZ:
359         xWorld = this->SM->GetSlicer(VisibleInWindow)->GetSlice()*
360                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetSpacing()[0] +
361                  this->SM->GetSlicer(VisibleInWindow)->GetInput()->GetOrigin()[0];
362         yWorld = y;
363         zWorld = z;
364         break;
365       }
366       this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(xWorld,yWorld,zWorld,
367           this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
368       if (newLandmark) {
369         this->SM->AddLandmark(xWorld,yWorld,zWorld,
370                               this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
371         this->SM->GetSlicer(VisibleInWindow)->UpdateLandmarks();
372         this->SM->Render();
373       }
374       if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent) {
375         this->SM->Picked();
376         this->SM->UpdateViews(1,VisibleInWindow);
377         this->SM->UpdateLinked(VisibleInWindow);
378         this->SM->UpdateInfoOnCursorPosition(VisibleInWindow);
379       } else {
380         this->SM->GetSlicer(VisibleInWindow)->Render();
381       }
382       //this->SM->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,
383       //-VTK_DOUBLE_MAX,this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
384       //this->SM->GetSlicer(VisibleInWindow)->Render();
385     }
386
387     if (event == vtkCommand::WindowLevelEvent && mStartSlicer > -1) {
388       this->SM->GetSlicer(mStartSlicer)->SetCornerAnnotationVisibility(1);
389       // Adjust the window level here
390       int *size = isi->GetInteractor()->GetRenderWindow()->GetSize();
391       double window = this->InitialWindow;
392       double level = this->InitialLevel;
393       double range[2];
394       this->SM->GetImage()->GetScalarRange(range);
395
396       // Compute normalized delta
397       double dx = static_cast<double>(isi->GetWindowLevelCurrentPosition()[0] -
398                                       isi->GetWindowLevelStartPosition()[0]) / size[0];
399       double dy = static_cast<double>(isi->GetWindowLevelStartPosition()[1] -
400                                       isi->GetWindowLevelCurrentPosition()[1]) / size[1];
401       //Window is exponential in nature, use exponential to avoid falling into negative numbers
402       dx = std::exp(1.0 * (dx*fabs(dx) + dx)) ; //Quadratic behavior for more reactive interface
403       dy = 0.15 * (dy*fabs(dy) + dy) * (range[1]-range[0]);//Quadratic behavior for more reactive interface
404
405       this->SM->SetColorWindow(window*dx);
406       this->SM->SetColorLevel(level-dy);
407       this->SM->SetPreset(6);
408       this->SM->UpdateWindowLevel();
409       this->SM->Render();
410       return;
411     }
412   }
413 }
414 //------------------------------------------------------------------------------
415
416
417 //------------------------------------------------------------------------------
418 void vvSlicerManagerCommand::Dolly(double factor, vtkRenderWindowInteractor *interactor)
419 {
420   int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
421   vtkRenderer* renderer;
422   if (VisibleInWindow>-1)
423     renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
424   else {
425     return;
426   }
427
428   double viewFocus[4],viewPoint[4],motionVector[3], focalDepth;
429   double oldPos[3], newPos[3], distance[2];
430   vtkCamera *camera = renderer->GetActiveCamera();
431   camera->GetFocalPoint(viewFocus);
432
433   renderer->SetWorldPoint(viewFocus[0], viewFocus[0], viewFocus[0], 1.0);
434   renderer->WorldToDisplay();
435   renderer->GetDisplayPoint(viewFocus);
436
437   focalDepth = viewFocus[2];
438
439   oldPos[0] = renderer->GetCenter()[0];
440   oldPos[1] = renderer->GetCenter()[1];
441   oldPos[2] = focalDepth;
442
443   distance[0] = 1/factor*
444                 (interactor->GetEventPosition()[0]-renderer->GetCenter()[0]);
445   distance[1] = 1/factor*
446                 (interactor->GetEventPosition()[1]-renderer->GetCenter()[1]);
447
448   newPos[0] = interactor->GetEventPosition()[0] - distance[0];
449   newPos[1] = interactor->GetEventPosition()[1] - distance[1];
450   newPos[2] = focalDepth;
451
452   renderer->DisplayToNormalizedDisplay(oldPos[0],oldPos[1]);
453   renderer->NormalizedDisplayToViewport(oldPos[0],oldPos[1]);
454   renderer->ViewportToNormalizedViewport(oldPos[0],oldPos[1]);
455   renderer->NormalizedViewportToView(oldPos[0],oldPos[1],oldPos[2]);
456   renderer->ViewToWorld(oldPos[0],oldPos[1],oldPos[2]);
457
458   renderer->DisplayToNormalizedDisplay(newPos[0],newPos[1]);
459   renderer->NormalizedDisplayToViewport(newPos[0],newPos[1]);
460   renderer->ViewportToNormalizedViewport(newPos[0],newPos[1]);
461   renderer->NormalizedViewportToView(newPos[0],newPos[1],newPos[2]);
462   renderer->ViewToWorld(newPos[0],newPos[1],newPos[2]);
463
464   motionVector[0] = newPos[0] - oldPos[0];
465   motionVector[1] = newPos[1] - oldPos[1];
466   motionVector[2] = newPos[2] - oldPos[2];
467
468   camera->GetFocalPoint(viewFocus);
469   camera->GetPosition(viewPoint);
470   camera->SetFocalPoint(motionVector[0] + viewFocus[0],
471                         motionVector[1] + viewFocus[1],
472                         motionVector[2] + viewFocus[2]);
473
474   camera->SetPosition(motionVector[0] + viewPoint[0],
475                       motionVector[1] + viewPoint[1],
476                       motionVector[2] + viewPoint[2]);
477
478   if (camera->GetParallelProjection()) {
479     camera->SetParallelScale(camera->GetParallelScale() / factor);
480   } else {
481     camera->Dolly(factor);
482   }
483
484   if (interactor->GetLightFollowCamera()) {
485     renderer->UpdateLightsGeometryToFollowCamera();
486   }
487   renderer->ResetCameraClippingRange();
488   //interactor->Render();
489 }
490 //------------------------------------------------------------------------------
491
492
493 //------------------------------------------------------------------------------
494 void vvSlicerManagerCommand::FlyToPosition(vtkRenderWindowInteractor *interactor,vvSlicer* slicer)
495 {
496   double flyFrom[3], flyTo[3];
497   double d[3], focalPt[3], position[3], positionFrom[3];
498   int i, j;
499   int VisibleInWindow = this->FindSlicerNumber(interactor->GetRenderWindow());
500   vtkRenderer* renderer=NULL;
501   if (VisibleInWindow>-1)
502     renderer=this->SM->GetSlicer(VisibleInWindow)->GetRenderer();
503   else
504     return;
505
506   interactor->GetPicker()->Pick(interactor->GetEventPosition()[0],
507                                 interactor->GetEventPosition()[1], 0.0,
508                                 renderer);
509
510   vtkAssemblyPath *path=NULL;
511   vtkAbstractPropPicker *picker;
512   if ( (picker=vtkAbstractPropPicker::SafeDownCast(interactor->GetPicker()))) {
513     path = picker->GetPath();
514   }
515   if ( path != NULL ) {
516     flyTo[0] = picker->GetPickPosition()[0];
517     flyTo[1] = picker->GetPickPosition()[1];
518     flyTo[2] = picker->GetPickPosition()[2];
519     renderer->GetActiveCamera()->GetFocalPoint(flyFrom);
520     renderer->GetActiveCamera()->GetPosition(positionFrom);
521
522     switch (slicer->GetSliceOrientation()) {
523     case vtkImageViewer2::SLICE_ORIENTATION_XY:
524       flyTo[2] = flyFrom[2];
525       break;
526
527     case vtkImageViewer2::SLICE_ORIENTATION_XZ:
528       flyTo[1] = flyFrom[1];
529       break;
530
531     case vtkImageViewer2::SLICE_ORIENTATION_YZ:
532       flyTo[0] = flyFrom[0];
533       break;
534     }
535
536
537     for (i=0; i<3; i++) {
538       d[i] = flyTo[i] - flyFrom[i];
539     }
540     double distance = vtkMath::Normalize(d);
541     double delta = distance/15;
542
543     for (i=1; i<=15; i++) {
544       for (j=0; j<3; j++) {
545         focalPt[j] = flyFrom[j] + d[j]*i*delta;
546         position[j] = positionFrom[j] + d[j]*i*delta;
547       }
548       renderer->GetActiveCamera()->SetFocalPoint(focalPt);
549       renderer->GetActiveCamera()->SetPosition(position);
550       renderer->GetActiveCamera()->Dolly(0.3/15 + 1.0);
551       renderer->ResetCameraClippingRange();
552       interactor->Render();
553     }
554   }
555 }
556 //------------------------------------------------------------------------------