SMILX  1.01
milxQtRenderWindow.cpp
1 /*=========================================================================
2  The Software is copyright (c) Commonwealth Scientific and Industrial Research Organisation (CSIRO)
3  ABN 41 687 119 230.
4  All rights reserved.
5 
6  Licensed under the CSIRO BSD 3-Clause License
7  You may not use this file except in compliance with the License.
8  You may obtain a copy of the License in the file LICENSE.md or at
9 
10  https://stash.csiro.au/projects/SMILI/repos/smili/browse/license.txt
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 =========================================================================*/
18 #include "milxQtRenderWindow.h"
19 
20 #include <vtkRendererCollection.h>
21 #include <vtkPropAssembly.h>
22 #include <vtkCamera.h>
23 #include <vtkCaptionActor2D.h>
24 #include <vtkTextActor.h>
25 #include <vtkTextProperty.h>
26 #include <vtkDistanceRepresentation.h>
27 #include <vtkPolyDataMapper.h>
28 #include <vtkProperty.h>
29 #include <vtkWidgetEventTranslator.h>
30 #include <vtkOrientedGlyphContourRepresentation.h>
31 #include <vtkBoxRepresentation.h>
32 #include <vtkWidgetEvent.h>
33 #include <vtkTransformPolyDataFilter.h>
34 #include <vtkPolyDataNormals.h>
35 #include <vtkCellArray.h> //needed for loading orientation glyph model
36 #include <vtkFloatArray.h> //needed for loading orientation glyph model
37 #include <vtkPointData.h>//needed for loading orientation glyph model
38 #if VTK_MAJOR_VERSION > 5
39  #include <vtkImageMapper3D.h>
40 #endif
41 
42 #include "milxColourMap.h"
43 #include "milxFile.h"
44 
45 milxQtRenderWindow::milxQtRenderWindow(QWidget *theParent, bool contextSystem) : milxQtWindow(theParent)
46 {
48  loaded = false;
49  rendered = false;
50  axesBefore = false;
51  scaleBefore = false;
52  customScalarBar = false;
53  logScale = false;
54  useDefaultView = true;
55  orientationAxes = true;
56  contextMenuEnabled = contextSystem;
57  defaultView = AXIAL; //axial
58  currentView = AXIAL; //axial
59  orientationView = RADIOLOGICAL;
60 
62  renderer = vtkSmartPointer<vtkRenderer>::New();
63  lookupTable = vtkSmartPointer<vtkLookupTable>::New();
64  camera = vtkSmartPointer<vtkCamera>::New();
65 
66  renderer->SetActiveCamera(camera);
67  renderer->ResetCamera();
68 
69  contextMenuSystem(contextMenuEnabled); //also sets up render window object and widgets
70 
71  //orientation glyph (showing equivalent view on human) setup
73 
74  setAcceptDrops(true);
75 
76  createActions();
77 
78  Connector = vtkSmartPointer<vtkEventQtSlotConnect>::New();
79 
81 
82  reset();
83 }
84 
86 {
87  textWidgets.clear();
88  textActors.clear();
89 }
90 
92 {
93  renderWindow = vtkSmartPointer<vtkRenderWindow>::New();
94  QVTKWidget::SetRenderWindow(renderWindow);
95  QVTKWidget::GetRenderWindow()->StereoRenderOff();
96  #if(VTK_MAJOR_VERSION < 6)
97  QVTKWidget::GetRenderWindow()->ReportGraphicErrorsOn();
98  #endif
99 
100  //widget setups
101  SetupWidgets(QVTKWidget::GetInteractor());
102 
104  QVTKWidget::GetRenderWindow()->GetInteractor()->SetDesiredUpdateRate(20); //for LOD actors
105  QVTKWidget::GetRenderWindow()->GetInteractor()->SetStillUpdateRate(0.01); //for LOD actors
106 
107  if(context)
108  {
110  QVTKWidget::GetRenderWindow()->GetInteractor()->RemoveObservers(vtkCommand::RightButtonPressEvent);
111  QVTKWidget::GetRenderWindow()->GetInteractor()->RemoveObservers(vtkCommand::RightButtonReleaseEvent);
112  }
113 }
114 
116 {
117  Connector->Connect(obj,
118  vtkCommand::ProgressEvent,
119  this,
120  SLOT( updateQtEvents() ),
121  NULL, 1.0); //High Priority
122 }
123 
124 void milxQtRenderWindow::SetupWidgets(vtkRenderWindowInteractor *interactor)
125 {
126  //distance widget setup
127  lineWidget = vtkSmartPointer<vtkLineWidget2>::New();
128  lineWidget->SetInteractor(interactor);
129  lineWidget->CreateDefaultRepresentation();
130 
131  //distance widget setup
132  distanceWidget = vtkSmartPointer<vtkDistanceWidget>::New();
133  distanceWidget->SetInteractor(interactor);
134  distanceWidget->CreateDefaultRepresentation();
135  vtkDistanceRepresentation::SafeDownCast(distanceWidget->GetRepresentation())->SetLabelFormat("%-#6.3g mm");
136 
137  //cross distance widget setup
138  biDirectionWidget = vtkSmartPointer<vtkBiDimensionalWidget>::New();
139  biDirectionWidget->SetInteractor(interactor);
140  biDirectionWidget->CreateDefaultRepresentation();
141 
142  //angle widget setup
143  angleWidget = vtkSmartPointer<vtkAngleWidget>::New();
144  angleWidget->SetInteractor(interactor);
145  angleWidget->CreateDefaultRepresentation();
146 
147  //plane widget setup
148  planeWidget = vtkSmartPointer<vtkPlaneWidget>::New();
149  planeWidget->SetInteractor(interactor);
150 
151  //box widget
152  boxWidget = vtkSmartPointer<vtkBoxWidget2>::New();
153  boxWidget->SetInteractor(interactor);
154  //boxWidget->CreateDefaultRepresentation();
155 
156  vtkSmartPointer<vtkBoxRepresentation> boxRepresentation = vtkSmartPointer<vtkBoxRepresentation>::New();
157  boxWidget->SetRepresentation(boxRepresentation);
158 
159  //sphere widget setup
160  sphereRep = vtkSmartPointer<vtkSphereRepresentation>::New();
161  sphereRep->SetRepresentationToWireframe();
162  sphereRep->SetThetaResolution(36);
163  sphereRep->SetPhiResolution(36);
164  sphereRep->SetRadius(10);
165  sphereRep->HandleTextOn();
166  sphereRep->RadialLineOn();
167  sphereRep->HandleVisibilityOn();
168  sphereWidget = vtkSmartPointer<vtkSphereWidget2>::New();
169  sphereWidget->SetInteractor(interactor);
170 // sphereWidget->CreateDefaultRepresentation();
171  sphereWidget->SetRepresentation(sphereRep);
172  sphereWidget->ScalingEnabledOn();
173  // Change bindings.
174  vtkWidgetEventTranslator *eventTranslator = sphereWidget->GetEventTranslator();
175  //unbind
176 // eventTranslator->RemoveTranslation( vtkCommand::LeftButtonPressEvent );
177 // eventTranslator->RemoveTranslation( vtkCommand::LeftButtonReleaseEvent );
178  eventTranslator->RemoveTranslation( vtkCommand::MiddleButtonPressEvent );
179  eventTranslator->RemoveTranslation( vtkCommand::MiddleButtonReleaseEvent );
180  eventTranslator->RemoveTranslation( vtkCommand::RightButtonPressEvent );
181  eventTranslator->RemoveTranslation( vtkCommand::RightButtonReleaseEvent );
182  //bind
183 // eventTranslator->SetTranslation(vtkCommand::LeftButtonPressEvent, vtkWidgetEvent::Scale);
184 // eventTranslator->SetTranslation(vtkCommand::LeftButtonReleaseEvent, vtkWidgetEvent::EndScale);
185 // eventTranslator->SetTranslation(vtkCommand::MiddleButtonPressEvent, vtkWidgetEvent::Translate);
186 // eventTranslator->SetTranslation(vtkCommand::MiddleButtonReleaseEvent, vtkWidgetEvent::EndTranslate);
187  eventTranslator->SetTranslation(vtkCommand::MiddleButtonPressEvent, vtkWidgetEvent::Scale);
188  eventTranslator->SetTranslation(vtkCommand::MiddleButtonReleaseEvent, vtkWidgetEvent::EndScale);
189 // eventTranslator->SetTranslation(vtkCommand::MouseMoveEvent, vtkWidgetEvent::Scale);
190 }
191 
193 {
194  if(!contourWidget)
195  contourWidget = vtkSmartPointer<vtkContourWidget>::New();
196  contourWidget->SetInteractor(QVTKWidget::GetInteractor());
197 
198  if(contourAct->isChecked())
199  {
200  contourWidget->EnabledOn();
201  printInfo("Enabled Contouring");
202  }
203  else
204  {
205  contourWidget->EnabledOff();
206  printInfo("Disabled Contouring");
207  }
208 
209 // vtkSmartPointer<vtkOrientedGlyphContourRepresentation> rep = vtkOrientedGlyphContourRepresentation::SafeDownCast( contourWidget->GetRepresentation() );
210 // rep->GetLinesProperty()->SetColor(1, 0.2, 0);
211 // rep->GetLinesProperty()->SetLineWidth(3.0);
212 //
213 // vtkSmartPointer<vtkImageActorPointPlacer> pointPlacer = vtkSmartPointer<vtkImageActorPointPlacer>::New();
214 // pointPlacer->AddProp(modelActor);
215 // pointPlacer->GetPolys()->AddItem(currentMesh);
216 // rep->SetPointPlacer(pointPlacer);
217 //
218 // vtkSmartPointer<vtkDijkstraImageContourLineInterpolator> interpolator = vtkSmartPointer<vtkDijkstraImageContourLineInterpolator>::New();
219 // interpolator->GetPolys()->AddItem(currentMesh);
220 // rep->SetLineInterpolator(interpolator);
221 
222  refresh();
223 }
224 
226 {
227  if(!contourAct->isChecked())
228  return;
229 
230  vtkSmartPointer<vtkContourRepresentation> rep = contourWidget->GetContourRepresentation();
231 
232  //rep->GetContourRepresentationAsPolyData() gives intermediate points also
233  //GetNodePolyData() gives only the nodes placed by user
234  emit modelAvailable(rep->GetContourRepresentationAsPolyData(), "Contour Model");
235 }
236 
238 {
239  if(!contourAct->isChecked())
240  return;
241 
242  vtkSmartPointer<vtkContourRepresentation> rep = contourWidget->GetContourRepresentation();
243 
244  vtkSmartPointer<vtkPolyData> nodes = vtkSmartPointer<vtkPolyData>::New();
245  rep->GetNodePolyData(nodes);
246 
247  //rep->GetContourRepresentationAsPolyData() gives intermediate points also
248  //GetNodePolyData() gives only the nodes placed by user
249  emit modelAvailable(nodes, "Contour");
250 }
251 
253 {
254  if(!contourAct->isChecked())
255  return;
256 
257  QSettings settings("Shekhar Chandra", "milxQt");
258  //Add supported file entry
259  QString exts = openModelExts.c_str();
260  QString path = settings.value("recentPath").toString();
261 
262  if(filename.isEmpty())
263  {
264  QFileDialog *fileOpener = new QFileDialog(this);
265  filename = fileOpener->getOpenFileName(this,
266  tr("Select Model(s) to Open"),
267  path,
268  tr(exts.toStdString().c_str()) );
269  }
270 
271  printDebug("Opening contour model");
272  vtkSmartPointer<vtkPolyData> mesh;
273  milx::File::OpenModel(filename.toStdString(), mesh);
274 
275  printDebug("Initialising Contouring");
276  contourWidget->On();
277  contourWidget->Initialize(mesh);
278  contourWidget->Render();
279 }
280 
281 void milxQtRenderWindow::enableAxes(float xScale, float yScale, float zScale)
282 {
283  if(!axes)
284  axes = vtkSmartPointer<vtkAxesActor>::New();
285 
286  axes->SetTotalLength(xScale, yScale, zScale);
287  axes->GetXAxisCaptionActor2D()->GetTextActor()->SetTextScaleModeToViewport();
288  axes->GetYAxisCaptionActor2D()->GetTextActor()->SetTextScaleModeToViewport();
289  axes->GetZAxisCaptionActor2D()->GetTextActor()->SetTextScaleModeToViewport();
290 
291  AddActor(axes);
292  axesBefore = true;
293 }
294 
296 {
297  if(!axesBefore)
298  return; //nothing to do then
299 
300  RemoveActor(axes);
301  axesBefore = false;
302 }
303 
305 {
306  if(backgroundAct->isChecked() || white)
307  {
308  renderer->GradientBackgroundOff();
309  renderer->SetBackground(1 , 1, 1);
310  backgroundAct->setChecked(true);
311  if(orientAxes)
312  {
313  orientAxes->GetXAxisCaptionActor2D()->GetTextActor()->GetTextProperty()->SetColor(0, 0, 0);
314  orientAxes->GetYAxisCaptionActor2D()->GetTextActor()->GetTextProperty()->SetColor(0, 0, 0);
315  orientAxes->GetZAxisCaptionActor2D()->GetTextActor()->GetTextProperty()->SetColor(0, 0, 0);
316  }
317  }
318  else
319  {
320  renderer->GradientBackgroundOn();
321  renderer->SetBackground(1 , 1, 1);
322  //renderer->SetBackground2(0.6, 0.5, 0.4);
323  renderer->SetBackground2(0.4, 0.5, 0.6);
324  if(orientAxes)
325  {
326  orientAxes->GetXAxisCaptionActor2D()->GetTextActor()->GetTextProperty()->SetColor(1.0, 1.0, 1.0);
327  orientAxes->GetYAxisCaptionActor2D()->GetTextActor()->GetTextProperty()->SetColor(1.0, 1.0, 1.0);
328  orientAxes->GetZAxisCaptionActor2D()->GetTextActor()->GetTextProperty()->SetColor(1.0, 1.0, 1.0);
329  }
330  }
331 
332  Render();
333 }
334 
336 {
337  if(axesAct->isChecked())
338  enableAxes();
339  else
340  disableAxes();
341 
342  refresh();
343 }
344 
346 {
347  humanAct->setChecked(false);
348  refresh();
349 }
350 
352 {
353  humanAct->setChecked(!humanAct->isChecked());
354  refresh();
355 }
356 
358 {
359  if(lightingAct->isChecked())
360  renderer->TwoSidedLightingOn();
361  else
362  {
363  renderer->TwoSidedLightingOff();
364  printInfo("Disabled Two-Sided Lighting.");
365  }
366 
367  Render();
368 }
369 
371 {
372  bool ok, ok1, ok2, ok3;
373  QString newText = QInputDialog::getText(this, tr("Please Enter text"),
374  tr("Text:"), QLineEdit::Normal, "A", &ok);
375  float rValue = QInputDialog::getDouble(this, tr("Please Provide red channel (0.0-1.0)"),
376  tr("Red:"), 1.0, -2147483647, 2147483647, 3, &ok1);
377  float gValue = QInputDialog::getDouble(this, tr("Please Provide green channel (0.0-1.0)"),
378  tr("Green:"), 0.0, -2147483647, 2147483647, 3, &ok2);
379  float bValue = QInputDialog::getDouble(this, tr("Please Provide blue channel (0.0-1.0)"),
380  tr("Blue:"), 0.0, -2147483647, 2147483647, 3, &ok3);
381 
382  if(!ok || !ok1 || !ok2 || !ok3)
383  return;
384 
385  vtkSmartPointer<vtkTextActor> textActor = vtkSmartPointer<vtkTextActor>::New();
386  textActor->SetInput(newText.toStdString().c_str());
387  textActor->SetTextScaleModeToProp();
388  textActor->GetTextProperty()->SetColor( rValue, gValue, bValue );
389  textActors.append(textActor);
390 
391  vtkSmartPointer<vtkTextWidget> textWidget = vtkSmartPointer<vtkTextWidget>::New();
392  textWidget->SetInteractor(QVTKWidget::GetInteractor());
393  textWidget->SetTextActor(textActor);
394  textWidget->On();
395  textWidgets.append(textWidget);
396 
397  Connector->Connect(textWidget,
398  vtkCommand::WidgetActivateEvent,
399  this,
400  SLOT( updateTextActor(vtkObject*, unsigned long, void*, void*, vtkCommand*) )); //High Priority
401 
402  Render();
403 }
404 
406 {
407  printDebug("Toggling Crosshair.");
408  Render();
409 
410  if(crosshairAct->isChecked())
411  enableCrosshair();
412  else
414 }
415 
417 {
418  if(rendered)
419  {
420  //viewToAxial
421  vtkCamera *cam = milxQtRenderWindow::GetRenderer()->GetActiveCamera();
422  milxQtRenderWindow::GetRenderer()->ResetCamera(); //just in case if new camera
423  cam->SetFocalPoint(0, 0, 0);
424  if(orientationView == RADIOLOGICAL)
425  {
426  cam->SetPosition(0,0,1);
427  cam->SetViewUp(0,-1,0);
428  }
429  else //Neurological
430  {
431  cam->SetPosition(0,0,-1);
432  cam->SetViewUp(0,1,0);
433  }
434  milxQtRenderWindow::GetRenderer()->ResetCamera(); //just in case if new camera
436 
437  currentView = AXIAL;
438  }
439 }
440 
442 {
443  if(rendered)
444  {
445  //viewToSagittal
446  vtkCamera *cam = milxQtRenderWindow::GetRenderer()->GetActiveCamera();
447  milxQtRenderWindow::GetRenderer()->ResetCamera(); //just in case if new camera
448  cam->SetFocalPoint(0, 0, 0);
449  if(orientationView == RADIOLOGICAL)
450  {
451  cam->SetPosition(0,-1,0);
452  cam->SetViewUp(0,0,1);
453  }
454  else //Neurological
455  {
456  cam->SetPosition(0,1,0);
457  cam->SetViewUp(0,0,1);
458  }
459  milxQtRenderWindow::GetRenderer()->ResetCamera(); //just in case if new camera
461 
462  currentView = CORONAL;
463  }
464 }
465 
467 {
468  if(rendered)
469  {
470  //viewToCoronal
471  vtkCamera *cam = milxQtRenderWindow::GetRenderer()->GetActiveCamera();
472  milxQtRenderWindow::GetRenderer()->ResetCamera(); //just in case if new camera
473  cam->SetFocalPoint(0, 0, 0);
474  cam->SetPosition(-1,0,0); //no orientation standard dependence
475  cam->SetViewUp(0,0,1);
476  milxQtRenderWindow::GetRenderer()->ResetCamera(); //just in case if new camera
478 
479  currentView = SAGITTAL;
480  }
481 }
482 
483 void milxQtRenderWindow::setView(int viewMode)
484 {
485  printDebug("Changing view to " + QString::number(viewMode));
486  if(viewMode == SAGITTAL) //sagittal
487  viewToSagittal();
488  else if(viewMode == CORONAL) //coronal
489  viewToCoronal();
490  else
491  viewToAxial();
492 }
493 
495 {
496  if(currentView == CORONAL) //sagittal
497  viewZX->setChecked(true);
498  else if(currentView == SAGITTAL) //coronal
499  viewZY->setChecked(true);
500  else
501  viewXY->setChecked(true);
502 }
503 
504 void milxQtRenderWindow::saveView(QString filename)
505 {
506  printInfo("Saving camera settings.");
507 
508  if(filename.isEmpty())
509  {
510  QSettings settings("Shekhar Chandra", "milxQt");
511 
512  settings.setValue("cameraSettings.ClippingRange.x", renderer->GetActiveCamera()->GetClippingRange()[0]);
513  settings.setValue("cameraSettings.ClippingRange.y", renderer->GetActiveCamera()->GetClippingRange()[1]);
514  // file << renderer->GetActiveCamera()->GetClippingRange()[0] << " "
515  // << renderer->GetActiveCamera()->GetClippingRange()[1] << " "
516 
517  settings.setValue("cameraSettings.FocalPoint.x", renderer->GetActiveCamera()->GetFocalPoint()[0]);
518  settings.setValue("cameraSettings.FocalPoint.y", renderer->GetActiveCamera()->GetFocalPoint()[1]);
519  settings.setValue("cameraSettings.FocalPoint.z", renderer->GetActiveCamera()->GetFocalPoint()[2]);
520  // << renderer->GetActiveCamera()->GetFocalPoint()[0] << " "
521  // << renderer->GetActiveCamera()->GetFocalPoint()[1] << " "
522  // << renderer->GetActiveCamera()->GetFocalPoint()[2] << " "
523 
524  settings.setValue("cameraSettings.Position.x", renderer->GetActiveCamera()->GetPosition()[0]);
525  settings.setValue("cameraSettings.Position.y", renderer->GetActiveCamera()->GetPosition()[1]);
526  settings.setValue("cameraSettings.Position.z", renderer->GetActiveCamera()->GetPosition()[2]);
527  // << renderer->GetActiveCamera()->GetPosition()[0] << " "
528  // << renderer->GetActiveCamera()->GetPosition()[1] << " "
529  // << renderer->GetActiveCamera()->GetPosition()[2] << " "
530 
531  settings.setValue("cameraSettings.ViewAngle", renderer->GetActiveCamera()->GetViewAngle());
532  // << renderer->GetActiveCamera()->GetViewAngle() << " "
533 
534  settings.setValue("cameraSettings.ViewUp.x", renderer->GetActiveCamera()->GetViewUp()[0]);
535  settings.setValue("cameraSettings.ViewUp.y", renderer->GetActiveCamera()->GetViewUp()[1]);
536  settings.setValue("cameraSettings.ViewUp.z", renderer->GetActiveCamera()->GetViewUp()[2]);
537  // << renderer->GetActiveCamera()->GetViewUp()[0] << " "
538  // << renderer->GetActiveCamera()->GetViewUp()[1] << " "
539  // << renderer->GetActiveCamera()->GetViewUp()[2] << " "
540  }
541  else
542  {
543  milx::File::SaveCamera(filename.toStdString(), renderer->GetActiveCamera());
544  }
545 }
546 
547 void milxQtRenderWindow::saveViewFile()
548 {
549  QFileDialog *fileSaver = new QFileDialog(this);
550  QSettings settings("Shekhar Chandra", "milxQt");
551  QString path = settings.value("recentPath").toString();
552 
553  QString filename = fileSaver->getSaveFileName(this,
554  tr("Select File Name to Save"),
555  path,
556  tr("Camera Files (*.cam *.txt)"));
557 
558  if(filename.isEmpty())
559  return;
560 
561  saveView(filename);
562 }
563 
564 void milxQtRenderWindow::loadView(QString filename)
565 {
566  printInfo("Laoding camera settings.");
567 
568  QFile file;
569  file.setFileName(filename);
570  if(!file.exists())
571  {
572  printWarning("File provided for loading did not exist. Using internally saved view instead");
573  filename = "";
574  }
575 
576  if(filename.isEmpty())
577  {
578  QSettings settings("Shekhar Chandra", "milxQt");
579 
580  double clippingRange[2];
581  clippingRange[0] = settings.value("cameraSettings.ClippingRange.x").toDouble();
582  clippingRange[1] = settings.value("cameraSettings.ClippingRange.y").toDouble();
583 
584  double focalPoint[3];
585  focalPoint[0] = settings.value("cameraSettings.FocalPoint.x").toDouble();
586  focalPoint[1] = settings.value("cameraSettings.FocalPoint.y").toDouble();
587  focalPoint[2] = settings.value("cameraSettings.FocalPoint.z").toDouble();
588 
589  double position[3];
590  position[0] = settings.value("cameraSettings.Position.x").toDouble();
591  position[1] = settings.value("cameraSettings.Position.y").toDouble();
592  position[2] = settings.value("cameraSettings.Position.z").toDouble();
593 
594  double angle = settings.value("cameraSettings.ViewAngle").toDouble();
595 
596  double viewUp[3];
597  viewUp[0] = settings.value("cameraSettings.ViewUp.x").toDouble();
598  viewUp[1] = settings.value("cameraSettings.ViewUp.y").toDouble();
599  viewUp[2] = settings.value("cameraSettings.ViewUp.z").toDouble();
600 
601  camera->SetClippingRange(clippingRange);
602  camera->SetFocalPoint(focalPoint);
603  camera->SetPosition(position);
604  camera->SetViewAngle(angle);
605  camera->SetViewUp(viewUp);
606  }
607  else
608  {
609  milx::File::LoadCamera(filename.toStdString(), camera);
610  }
611 
612  renderer->SetActiveCamera(camera);
613  QVTKWidget::GetRenderWindow()->Render();
614 }
615 
616 void milxQtRenderWindow::loadViewFile()
617 {
618  QFileDialog *fileOpener = new QFileDialog(this);
619  QSettings settings("Shekhar Chandra", "milxQt");
620  QString path = settings.value("recentPath").toString();
621 
622  QString filename = fileOpener->getOpenFileName(this,
623  tr("Select File to Open"),
624  path,
625  tr("Camera Files (*.cam *.txt)") );
626 
627  if(filename.isEmpty())
628  return;
629 
630  loadView(filename);
631 }
632 
633 void milxQtRenderWindow::addModelActor(vtkSmartPointer<vtkActor> mdlActor)
634 {
635  AddActor(mdlActor);
636  if(!rendered)
637  generateRender();
638 }
639 
640 void milxQtRenderWindow::removeModelActor(vtkSmartPointer<vtkActor> mdlActor)
641 {
642  RemoveActor(mdlActor);
643  if(!rendered)
644  generateRender();
645 }
646 
647 void milxQtRenderWindow::addActor(vtkSmartPointer<vtkActor> actor, vtkMatrix4x4 *transformMatrix)
648 {
649  vtkSmartPointer<vtkActor> rndActor = vtkSmartPointer<vtkActor>::New();
650  rndActor->SetMapper(actor->GetMapper());
651  if (transformMatrix)
652  rndActor->SetUserMatrix(transformMatrix);
653  AddActor(rndActor);
654 }
655 
656 void milxQtRenderWindow::addImageActor(vtkSmartPointer<vtkImageActor> imgActor, vtkMatrix4x4 *transformMatrix)
657 {
658  //Check if already in view
659  foreach(ImageActorItem item, imageActors)
660  {
661  if(imgActor == item.parentActor)
662  return; //Dont need to do anything.
663  }
664 
665  int extents[6];
666  imgActor->GetDisplayExtent(extents);
667 
668  //Copy window level and actor to avoid leveling bugs like actor going blank or white when multiple actors in 3D view
669  ImageActorItem item;
670  item.parentActor = imgActor;
671  item.imageActor = vtkSmartPointer<vtkImageActor>::New();
672  item.imageActor->SetDisplayExtent(extents);
673 #if(VTK_MAJOR_VERSION > 5)
674  item.imageActor->GetMapper()->SetInputData(imgActor->GetInput());
675 #else
676  item.imageActor->SetInput(imgActor->GetInput());
677 #endif
678  if(transformMatrix)
679  {
680 // printDebug("Transforming Actor to Image Space");
681  item.imageActor->SetUserMatrix( transformMatrix );
682  //Fix the actor properties, as they get reset to default ones. \todo fix this
683  }
685 // Connector->Connect(imgActor,
686 // vtkCommand::ModifiedEvent,
687 // this,
688 // SLOT( updateImageActor(vtkObject*, unsigned long, void*, void*, vtkCommand*) )); //High Priority
689 
690  //Added to image actor list
691  imageActors.append(item);
692 
693  AddActor( item.imageActor );
694  if(!rendered)
695  generateRender();
696 }
697 
698 void milxQtRenderWindow::updateTextActor(vtkObject * obj, unsigned long, void * client_data, void *, vtkCommand * command)
699 {
700  vtkSmartPointer<vtkTextWidget> textWidget = vtkTextWidget::SafeDownCast(obj);
701  vtkSmartPointer<vtkTextActor> textActor = textWidget->GetTextActor();
702 
703  QMessageBox msgBox;
704  msgBox.setText("Would you like to remove this text?");
705  msgBox.setInformativeText("Remove this text?");
706  msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
707  msgBox.setDefaultButton(QMessageBox::No);
708  int ret = msgBox.exec();
709 
710  if(ret == QMessageBox::No)
711  {
712  bool ok, ok1, ok2, ok3;
713  QString newText = QInputDialog::getText(this, tr("Please Enter text"),
714  tr("Text:"), QLineEdit::Normal, textActor->GetInput(), &ok);
715  float rValue = QInputDialog::getDouble(this, tr("Please Provide red channel (0.0-1.0)"),
716  tr("Red:"), 1.0, -2147483647, 2147483647, 3, &ok1);
717  float gValue = QInputDialog::getDouble(this, tr("Please Provide green channel (0.0-1.0)"),
718  tr("Green:"), 0.0, -2147483647, 2147483647, 3, &ok2);
719  float bValue = QInputDialog::getDouble(this, tr("Please Provide blue channel (0.0-1.0)"),
720  tr("Blue:"), 0.0, -2147483647, 2147483647, 3, &ok3);
721 
722  if(!ok || !ok1 || !ok2 || !ok3)
723  return;
724 
725  textActor->SetInput(newText.toStdString().c_str());
726  textActor->SetTextScaleModeToProp();
727  textActor->GetTextProperty()->SetColor( rValue, gValue, bValue );
728 
729  textWidget->SetTextActor(textActor);
730  }
731  else
732  textWidget->Off();
733 
734  Render();
735 }
736 
737 void milxQtRenderWindow::updateImageActor(vtkObject * obj, unsigned long, void * client_data, void *, vtkCommand * command)
738 {
739  vtkSmartPointer<vtkImageActor> actor = vtkImageActor::SafeDownCast(obj);
740 
741  //Update the actor which is somehere in list
742  foreach(ImageActorItem item, imageActors)
743  {
744  if(actor == item.parentActor)
745  {
746  int extents[6];
747 
748  actor->GetDisplayExtent(extents);
749 
750  item.imageActor->SetDisplayExtent(extents);
751  item.imageActor->SetInterpolate(actor->GetInterpolate());
752  // item.imageActor->SetInput(actor->GetInput());
753 
754  break; //Only one of each is allowed
755  }
756  }
757 
758  Render();
759 }
760 
761 void milxQtRenderWindow::updateImageActor(vtkSmartPointer<vtkImageActor> actor)
762 {
763  //Update the actor which is somehere in list
764  foreach(ImageActorItem item, imageActors)
765  {
766  if(actor == item.parentActor)
767  {
768  int extents[6];
769 
770  actor->GetDisplayExtent(extents);
771 
772  item.imageActor->SetDisplayExtent(extents);
773  item.imageActor->SetInterpolate(actor->GetInterpolate());
774 // item.imageActor->SetInput(actor->GetInput());
775 
776  break; //Only one of each is allowed
777  }
778  }
779 
780  Render();
781 }
782 
783 void milxQtRenderWindow::userEvent(QMouseEvent *event)
784 {
785 
786 }
787 
788 void milxQtRenderWindow::userEvent(QKeyEvent *event)
789 {
790 
791 }
792 
793 void milxQtRenderWindow::userEvent(QWheelEvent *event)
794 {
795 
796 }
797 
799 {
800  //Check widgets
801  if(lineAct->isChecked())
802  lineWidget->On(); //enable lines
803  else
804  lineWidget->Off();
805  if(distanceAct->isChecked())
806  distanceWidget->On(); //enable distance measuring
807  else
808  distanceWidget->Off();
809  if(biDirectionAct->isChecked())
810  biDirectionWidget->On(); //enable cross distance measuring
811  else
812  biDirectionWidget->Off();
813  if(angleAct->isChecked())
814  angleWidget->On(); //enable angle measuring
815  else
816  angleWidget->Off();
817  if(planeAct->isChecked())
818  planeWidget->On(); //enable plane drawing
819  else
820  planeWidget->Off();
821  if(boxAct->isChecked())
822  boxWidget->On(); //enable box drawing
823  else
824  boxWidget->Off();
825  if(sphereAct->isChecked())
826  sphereWidget->On(); //enable sphere drawing
827  else
828  sphereWidget->Off();
829  if(humanAct->isChecked())
830  humanGlyph->On(); //enable orientation glyph
831  else
832  humanGlyph->Off();
833 
834  Render();
835 }
836 
837 void milxQtRenderWindow::removeImageActor(vtkSmartPointer<vtkImageActor> imgActor)
838 {
839  ImageActorItem foundItem;
840 
841  //Check if already in view
842  size_t count = 0;
843  foreach(ImageActorItem item, imageActors)
844  {
845  if(imgActor == item.imageActor || imgActor == item.parentActor)
846  {
847  foundItem.imageActor = item.imageActor; //Dont need to do anything.
848  foundItem.parentActor = item.parentActor; //Dont need to do anything.
849  imageActors.removeAt(count);
850  break;
851  }
852  count ++;
853  }
854 
855  RemoveActor( foundItem.imageActor );
856  if(!rendered)
857  generateRender();
858 }
859 
861 {
862  if(windowToImportFrom)
863  {
864  if(windowToImportFrom->GetImageActor()) //Is image so...
865  {
866  //Transform actor to correct orientation
867  vtkSmartPointer<vtkMatrix4x4> transformModel = vtkSmartPointer<vtkMatrix4x4>::New();
868  transformModel->DeepCopy(windowToImportFrom->getTransformMatrix());
869  transformModel->Invert();
870 
871  addImageActor( windowToImportFrom->GetImageActor(), transformModel );
872 
875  connect(windowToImportFrom, SIGNAL(modified(vtkSmartPointer<vtkImageActor> )), this, SLOT(updateImageActor(vtkSmartPointer<vtkImageActor>)));
876  }
877  else
878  {
879  vtkActorCollection *actors = windowToImportFrom->GetActors();
880 
881  size_t n = actors->GetNumberOfItems();
882 
883  actors->InitTraversal();
884  for(size_t j = 0; j < n; j ++)
885  {
886  printDebug("Adding Generic Actor into scene.");
887 
888  addModelActor(actors->GetNextItem());
889 
890  qApp->processEvents();
891  }
892  }
893  Render();
894  }
895 }
896 
898 {
899  if(!scaleBefore)
900  return; //nothing to do then
901 
902  scalarBar->EnabledOff();
903  scaleAct->setChecked(false);
904  scaleBefore = false;
905 }
906 
907 void milxQtRenderWindow::colourMapToRainbow(double minRange, double maxRange)
908 {
909  double range[2];
910  if(minRange == 0.0 && maxRange == 0.0)
911  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
912  else
913  {
914  range[0] = minRange;
915  range[1] = maxRange;
916  }
917 
918  milx::ColourMap *colours = new milx::ColourMap;
919  colours->toRainbow();
920  colours->SetRange(range);
921 
922  lookupTable = colours->GetOutput();
923 
924  if(!actionRainbow->isChecked())
925  actionRainbow->setChecked(true);
926 
927  logScale = false;
929 }
930 
931 void milxQtRenderWindow::colourMapToVTK(double minRange, double maxRange)
932 {
933  double range[2];
934  if(minRange == 0.0 && maxRange == 0.0)
935  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
936  else
937  {
938  range[0] = minRange;
939  range[1] = maxRange;
940  }
941 
942  milx::ColourMap *colours = new milx::ColourMap;
943  colours->toVTK();
944  colours->SetRange(range);
945 
946  lookupTable = colours->GetOutput();
947 
948  if(!actionInvRainbow->isChecked())
949  actionInvRainbow->setChecked(true);
950 
951  logScale = false;
953 }
954 
955 void milxQtRenderWindow::colourMapToJet(double minRange, double maxRange)
956 {
957  double range[2];
958  if(minRange == 0.0 && maxRange == 0.0)
959  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
960  else
961  {
962  range[0] = minRange;
963  range[1] = maxRange;
964  }
965 
966  milx::ColourMap *colours = new milx::ColourMap;
967  colours->toJet();
968  colours->SetRange(range);
969 
970  lookupTable = colours->GetOutput();
971 
972  if(!actionJet->isChecked())
973  actionJet->setChecked(true);
974 
975  logScale = false;
977 }
978 
979 void milxQtRenderWindow::colourMapToGray(double minRange, double maxRange)
980 {
981  double range[2];
982  if(minRange == 0.0 && maxRange == 0.0)
983  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
984  else
985  {
986  range[0] = minRange;
987  range[1] = maxRange;
988  }
989 
990  milx::ColourMap *colours = new milx::ColourMap;
991  colours->toGray();
992  colours->SetRange(range);
993 
994  lookupTable = colours->GetOutput();
995 
996  if(!actionGray->isChecked())
997  actionGray->setChecked(true);
998 
999  logScale = false;
1001 }
1002 
1003 void milxQtRenderWindow::colourMapToSeismic(double minRange, double maxRange)
1004 {
1005  double range[2];
1006  if(minRange == 0.0 && maxRange == 0.0)
1007  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1008  else
1009  {
1010  range[0] = minRange;
1011  range[1] = maxRange;
1012  }
1013 
1014  milx::ColourMap *colours = new milx::ColourMap;
1015  colours->toSeismic();
1016  colours->SetRange(range);
1017 
1018  lookupTable = colours->GetOutput();
1019 
1020  if(!actionSeismic->isChecked())
1021  actionSeismic->setChecked(true);
1022 
1023  logScale = false;
1025 }
1026 
1027 void milxQtRenderWindow::colourMapToLogGray(double minRange, double maxRange)
1028 {
1029  double range[2];
1030  if(minRange == 0.0 && maxRange == 0.0)
1031  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1032  else
1033  {
1034  range[0] = minRange;
1035  range[1] = maxRange;
1036  }
1037 
1038  milx::ColourMap *colours = new milx::ColourMap;
1039  colours->toLogGray();
1040  colours->SetRange(range);
1041 
1042  lookupTable = colours->GetOutput();
1043 
1044  if(!actionLogGray->isChecked())
1045  actionLogGray->setChecked(true);
1046 
1047  logScale = true;
1049 }
1050 
1051 void milxQtRenderWindow::colourMapToNIH(double minRange, double maxRange)
1052 {
1053  double range[2];
1054  if(minRange == 0.0 && maxRange == 0.0)
1055  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1056  else
1057  {
1058  range[0] = minRange;
1059  range[1] = maxRange;
1060  }
1061 
1062  milx::ColourMap *colours = new milx::ColourMap;
1063  colours->toNIH();
1064  colours->SetRange(range);
1065 
1066  lookupTable = colours->GetOutput();
1067 
1068  if(!actionNIH->isChecked())
1069  actionNIH->setChecked(true);
1070 
1071  logScale = false;
1073 }
1074 
1075 void milxQtRenderWindow::colourMapToNIH_Fire(double minRange, double maxRange)
1076 {
1077  double range[2];
1078  if(minRange == 0.0 && maxRange == 0.0)
1079  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1080  else
1081  {
1082  range[0] = minRange;
1083  range[1] = maxRange;
1084  }
1085 
1086  milx::ColourMap *colours = new milx::ColourMap;
1087  colours->toNIH_FIRE();
1088  colours->SetRange(range);
1089 
1090  lookupTable = colours->GetOutput();
1091 
1092  if(!actionNIH_FIRE->isChecked())
1093  actionNIH_FIRE->setChecked(true);
1094 
1095  logScale = false;
1097 }
1098 
1099 void milxQtRenderWindow::colourMapToAAL(double minRange, double maxRange)
1100 {
1101  double range[2];
1102  if(minRange == 0.0 && maxRange == 0.0)
1103  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1104  else
1105  {
1106  range[0] = minRange;
1107  range[1] = maxRange;
1108  }
1109 
1110  milx::ColourMap *colours = new milx::ColourMap;
1111  colours->toAAL();
1112  colours->SetRange(range);
1113 
1114  lookupTable = colours->GetOutput();
1115 
1116  if(!actionAAL->isChecked())
1117  actionAAL->setChecked(true);
1118 
1119  logScale = false;
1121 }
1122 
1123 void milxQtRenderWindow::colourMapToFS(double minRange, double maxRange)
1124 {
1125  double range[2];
1126  if(minRange == 0.0 && maxRange == 0.0)
1127  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1128  else
1129  {
1130  range[0] = minRange;
1131  range[1] = maxRange;
1132  }
1133 
1134  milx::ColourMap *colours = new milx::ColourMap;
1135  colours->toFS(); //freesurfer
1136  colours->SetRange(range);
1137 
1138  lookupTable = colours->GetOutput();
1139 
1140  if(!actionFS->isChecked())
1141  actionFS->setChecked(true);
1142 
1143  logScale = false;
1145 }
1146 
1147 void milxQtRenderWindow::colourMapToHOT(double minRange, double maxRange)
1148 {
1149  double range[2];
1150  if(minRange == 0.0 && maxRange == 0.0)
1151  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1152  else
1153  {
1154  range[0] = minRange;
1155  range[1] = maxRange;
1156  }
1157 
1158  milx::ColourMap *colours = new milx::ColourMap;
1159  colours->toHOT();
1160  colours->SetRange(range);
1161 
1162  lookupTable = colours->GetOutput();
1163 
1164  if(!actionHOT->isChecked())
1165  actionHOT->setChecked(true);
1166 
1167  logScale = false;
1169 }
1170 
1171 void milxQtRenderWindow::colourMapToCOOL(double minRange, double maxRange)
1172 {
1173  double range[2];
1174  if(minRange == 0.0 && maxRange == 0.0)
1175  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1176  else
1177  {
1178  range[0] = minRange;
1179  range[1] = maxRange;
1180  }
1181 
1182  milx::ColourMap *colours = new milx::ColourMap;
1183  colours->toCOOL();
1184  colours->SetRange(range);
1185 
1186  lookupTable = colours->GetOutput();
1187 
1188  if(!actionCOOL->isChecked())
1189  actionCOOL->setChecked(true);
1190 
1191  logScale = false;
1193 }
1194 
1195 void milxQtRenderWindow::colourMapToCOOLWARM(double minRange, double maxRange)
1196 {
1197  double range[2];
1198  if(minRange == 0.0 && maxRange == 0.0)
1199  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1200  else
1201  {
1202  range[0] = minRange;
1203  range[1] = maxRange;
1204  }
1205 
1206  milx::ColourMap *colours = new milx::ColourMap;
1207  colours->toCOOLWARM();
1208  colours->SetRange(range);
1209 
1210  lookupTable = colours->GetOutput();
1211 
1212  if(!actionCOOLWARM->isChecked())
1213  actionCOOLWARM->setChecked(true);
1214 
1215  logScale = false;
1217 }
1218 
1219 void milxQtRenderWindow::colourMapToKnee(double minRange, double maxRange)
1220 {
1221  double range[2];
1222  if(minRange == 0.0 && maxRange == 0.0)
1223  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1224  else
1225  {
1226  range[0] = minRange;
1227  range[1] = maxRange;
1228  }
1229 
1230  milx::ColourMap *colours = new milx::ColourMap;
1231  colours->toKnee();
1232  colours->SetRange(range);
1233 
1234  lookupTable = colours->GetOutput();
1235 
1236  if(!actionKnee->isChecked())
1237  actionKnee->setChecked(true);
1238 
1239  logScale = false;
1241 }
1242 
1243 void milxQtRenderWindow::colourMapToBone(double minRange, double maxRange)
1244 {
1245  double range[2];
1246  if(minRange == 0.0 && maxRange == 0.0)
1247  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1248  else
1249  {
1250  range[0] = minRange;
1251  range[1] = maxRange;
1252  }
1253 
1254  milx::ColourMap *colours = new milx::ColourMap;
1255  colours->toBone();
1256  colours->SetRange(range);
1257 
1258  lookupTable = colours->GetOutput();
1259 
1260  if(!actionBone->isChecked())
1261  actionBone->setChecked(true);
1262 
1263  logScale = false;
1265 }
1266 
1267 void milxQtRenderWindow::colourMapToSpectral(double minRange, double maxRange)
1268 {
1269  double range[2];
1270  if(minRange == 0.0 && maxRange == 0.0)
1271  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1272  else
1273  {
1274  range[0] = minRange;
1275  range[1] = maxRange;
1276  }
1277 
1278  milx::ColourMap *colours = new milx::ColourMap;
1279  colours->toSpectral();
1280  colours->SetRange(range);
1281 
1282  lookupTable = colours->GetOutput();
1283 
1284  if(!actionSpectral->isChecked())
1285  actionSpectral->setChecked(true);
1286 
1287  logScale = false;
1289 }
1290 
1291 void milxQtRenderWindow::colourMapToGNUPlot(double minRange, double maxRange)
1292 {
1293  double range[2];
1294  if(minRange == 0.0 && maxRange == 0.0)
1295  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1296  else
1297  {
1298  range[0] = minRange;
1299  range[1] = maxRange;
1300  }
1301 
1302  milx::ColourMap *colours = new milx::ColourMap;
1303  colours->toGNUPlot();
1304  colours->SetRange(range);
1305 
1306  lookupTable = colours->GetOutput();
1307 
1308  if(!actionGNUPlot->isChecked())
1309  actionGNUPlot->setChecked(true);
1310 
1311  logScale = false;
1313 }
1314 
1315 void milxQtRenderWindow::colourMapToCubeHelix(double minRange, double maxRange)
1316 {
1317  double range[2];
1318  if(minRange == 0.0 && maxRange == 0.0)
1319  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1320  else
1321  {
1322  range[0] = minRange;
1323  range[1] = maxRange;
1324  }
1325 
1326  milx::ColourMap *colours = new milx::ColourMap;
1327  colours->toCubeHelix();
1328  colours->SetRange(range);
1329 
1330  lookupTable = colours->GetOutput();
1331 
1332  if(!actionCubeHelix->isChecked())
1333  actionCubeHelix->setChecked(true);
1334 
1335  logScale = false;
1337 }
1338 
1339 void milxQtRenderWindow::colourMapToHSV(double minRange, double maxRange)
1340 {
1341  double range[2];
1342  if(minRange == 0.0 && maxRange == 0.0)
1343  GetDataSet()->GetScalarRange(range); //This will propagate upwards to get the range for images or meshes
1344  else
1345  {
1346  range[0] = minRange;
1347  range[1] = maxRange;
1348  }
1349 
1350  milx::ColourMap *colours = new milx::ColourMap;
1351  colours->toHSV();
1352  colours->SetRange(range);
1353 
1354  lookupTable = colours->GetOutput();
1355 
1356  if(!actionHSV->isChecked())
1357  actionHSV->setChecked(true);
1358 
1359  logScale = false;
1361 }
1362 
1364 {
1365 
1366 }
1367 
1369 {
1370  if(!rendered)
1371  return;
1372 
1373  renderer->ResetCamera();
1374  refresh();
1375 }
1376 
1378 {
1379  printDebug("Generating Render");
1380 
1382  if(!GetImageActor()) //not image then
1383  background();
1384 
1386  if(QVTKWidget::GetRenderWindow()->GetRenderers()->GetNumberOfItems() == 0 || renderer != QVTKWidget::GetRenderWindow()->GetRenderers()->GetFirstRenderer()) //support only single renderer atm
1387  QVTKWidget::GetRenderWindow()->AddRenderer(renderer);
1388 
1390  printDebug("Size of window: " + QString::number(QVTKWidget::size().height()) + "x" + QString::number(QVTKWidget::size().width()));
1391  printDebug("Actual Size of window: " + QString::number(QVTKWidget::GetRenderWindow()->GetSize()[0]) + "x" + QString::number(QVTKWidget::GetRenderWindow()->GetSize()[1]));
1392  if(QVTKWidget::size().height() < minWindowSize || QVTKWidget::size().width() < minWindowSize)
1393  {
1394  QVTKWidget::GetRenderWindow()->SetSize(minWindowSize, minWindowSize);
1395  printDebug("Resized to minimum size");
1396  }
1397 
1398  int *winSize = QVTKWidget::GetRenderWindow()->GetSize();
1399  QVTKWidget::resize(winSize[0], winSize[1]);
1400 
1401  reset();
1402 
1403  rendered = true;
1404  printDebug("Completed Generating Render");
1405 }
1406 
1407 void milxQtRenderWindow::createCustomConnections(QList<QAction *> actionsInMenu)
1408 {
1409  foreach(QAction *action, actionsInMenu)
1410  {
1411  printDebug("Adding action for custom operations.");
1412  connect(action, SIGNAL(triggered()), this, SLOT(customOperation()));
1413  }
1414 }
1415 
1416 void milxQtRenderWindow::createCustomConnections(QMenu *fromMenu)
1417 {
1418  QList<QAction *> actionsInMenu = fromMenu->actions();
1419 
1420  foreach(QAction *action, actionsInMenu)
1421  {
1422  printDebug("Adding action for custom operations.");
1423  connect(action, SIGNAL(triggered()), this, SLOT(customOperation()));
1424  }
1425 }
1426 
1428 {
1429  milxQtRenderWindow *currentWindow = qobject_cast<milxQtRenderWindow *>( windowActionGroup->checkedAction()->parent() );
1430 
1431  if(currentWindow == 0)
1432  {
1433  printError("Error in determining parent of action");
1434  return;
1435  }
1436 
1437  printDebug("Checked Window is: " + currentWindow->strippedNamePrefix());
1438 
1439  //Check for image actor
1440  if(currentWindow->GetImageActor()) //Is image so...
1441  {
1442  //Transform actor to correct orientation
1443  vtkSmartPointer<vtkMatrix4x4> transformModel = vtkSmartPointer<vtkMatrix4x4>::New();
1444  transformModel->DeepCopy(currentWindow->getTransformMatrix());
1445  transformModel->Invert();
1446 
1447  addImageActor( currentWindow->GetImageActor(), transformModel );
1448 
1451  connect(currentWindow, SIGNAL(modified(vtkSmartPointer<vtkImageActor> )), this, SLOT(updateImageActor(vtkSmartPointer<vtkImageActor>)));
1452  }
1453  else
1454  {
1455  vtkActorCollection *actors = currentWindow->GetActors();
1456 
1457  size_t n = actors->GetNumberOfItems();
1458 
1459  actors->InitTraversal();
1460  for(size_t j = 0; j < n; j ++)
1461  {
1462  printDebug("Adding Generic Actor into scene.");
1463 
1464  addModelActor(actors->GetNextItem());
1465 
1466  qApp->processEvents();
1467  }
1468  }
1469 
1470  Render();
1471 }
1472 
1474 {
1475  if(!menu)
1476  return;
1477 
1478  menu->clear();
1479 
1480  foreach(QAction *currAct, milxQtWindow::actionsToAdd)
1481  {
1482  menu->addAction(currAct);
1483  }
1484  foreach(QMenu *currMenu, milxQtWindow::menusToAdd)
1485  {
1486  menu->addMenu(currMenu);
1487  }
1488  contourPolyDataAct->setDisabled(!contourAct->isChecked());
1489  contourInitAct->setDisabled(!contourAct->isChecked());
1490  // contourImageAct->setDisabled(!contourAct->isChecked());
1491 
1492  menu->addMenu(contourMenu);
1493  menu->addAction(backgroundAct);
1494  menu->addAction(axesAct);
1495  menu->addAction(lightingAct);
1496  menu->addAction(lineAct);
1497  menu->addAction(distanceAct);
1498  menu->addAction(biDirectionAct);
1499  menu->addAction(angleAct);
1500  menu->addAction(planeAct);
1501  menu->addAction(boxAct);
1502  menu->addAction(sphereAct);
1503  menu->addAction(humanAct);
1504  menu->addAction(textAct);
1505 
1507  menu->addMenu(viewMenu);
1508  viewMenu->addAction(viewXY);
1509  viewMenu->addAction(viewZX);
1510  viewMenu->addAction(viewZY);
1511  viewMenu->addAction(saveViewAct);
1512  viewMenu->addAction(saveViewFileAct);
1513  viewMenu->addAction(loadViewAct);
1514  viewMenu->addAction(loadViewFileAct);
1516  colourMapsMenu();
1517 
1518  menu->addSeparator();
1519  foreach(QAction *currAct, milxQtWindow::actionsToAppend)
1520  {
1521  menu->addAction(currAct);
1522  }
1523  foreach(QMenu *currMenu, milxQtWindow::menusToAppend)
1524  {
1525  menu->addMenu(currMenu);
1526  }
1527 
1528  menu->addAction(refreshAct);
1529  menu->addAction(resetAct);
1530 }
1531 
1532 bool milxQtRenderWindow::openModelUsingQt(const QString filename, vtkSmartPointer<vtkPolyData> &data)
1533 {
1534  QFile qtFile(filename);
1535  if(!qtFile.open(QIODevice::ReadOnly))
1536  {
1537  printError("Unable to open model using Qt for reading.");
1538  return false;
1539  }
1540 
1541  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
1542  vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
1543  vtkSmartPointer<vtkFloatArray> normals = vtkSmartPointer<vtkFloatArray>::New();
1544  normals->SetNumberOfComponents(3);
1545 
1546  QTextStream inFile(&qtFile);
1547  while (!inFile.atEnd())
1548  {
1549  QString lineType;
1550  inFile >> lineType;
1551 
1552  if(lineType == "" || lineType == "#" || lineType == "mtllib" || lineType == "usemtl" || lineType == "g" || lineType == "s" || lineType == "vt") //no material, texture or scalars support yet
1553  continue;
1554  else if(lineType == "v") //vertices v
1555  {
1556  double position[3];
1557  inFile >> position[0] >> position[1] >> position[2];
1558 // qDebug() << position[0] << "," << position[1] << "," << position[2];
1559  points->InsertNextPoint(position);
1560  }
1561  else if(lineType == "vn") //normals vn
1562  {
1563  float normal[3];
1564  inFile >> normal[0] >> normal[1] >> normal[2];
1565 // qDebug() << normal[0] << "," << normal[1] << "," << normal[2];
1566  normals->InsertNextTupleValue(normal);
1567  }
1568  else if(lineType == "f") //faces/cells
1569  {
1570  QString face[3];
1571  inFile >> face[0] >> face[1] >> face[2];
1572  // v/vt/vn format read
1573 
1574  cells->InsertNextCell(3);
1575  for(size_t j = 0; j < 3; j ++)
1576  {
1577  QStringList faceParts = face[j].split('/');
1578 // qDebug() << faceParts;
1579  cells->InsertCellPoint(faceParts[0].toInt()-1); //obj indices indexed from 1 not 0
1580  }
1581  }
1582  }
1583 
1584  if(!data)
1585  data = vtkSmartPointer<vtkPolyData>::New();
1586  data->SetPoints(points);
1587  data->SetPolys(cells);
1588  data->GetPointData()->SetNormals(normals);
1589 
1590  return true;
1591 }
1592 
1594 {
1595  if(!dataPicker)
1596  dataPicker = vtkSmartPointer<vtkPointPicker>::New();
1597 
1598  Connector->Connect( QVTKWidget::GetRenderWindow()->GetInteractor(),
1599  vtkCommand::MouseMoveEvent,
1600  this,
1601  SLOT( updateCoords(vtkObject*) ) );
1602 
1603  updateBar = bar;
1604 }
1605 
1607 {
1609  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::SafeDownCast(obj);
1610 
1611  QString message = "";
1612 
1617  if (dataPicker->Pick(iren->GetEventPosition()[0],
1618  iren->GetEventPosition()[1],
1619  0, // always zero.
1620  renderer))
1621  {
1622  // Get the mapped position of the mouse using the picker.
1623  double point[3];
1624  dataPicker->GetPickPosition(point);
1625 
1626  // Get the volume index within the entire volume now.
1627  vtkIdType nVolIdx = dataPicker->GetPointId();
1628 
1629  message = "Point " + QString::number(nVolIdx) + ": (" + QString::number(point[0]) + ", " + QString::number(point[1]) + ", " + QString::number(point[2]) + ")";
1630  }
1631 
1633  updateBar->showMessage(message);
1634 }
1635 
1637 {
1638  contextMenu = new QMenu(this);
1639  contextMenu->setTitle(QApplication::translate("MainWindow", "Rendering", 0, QApplication::UnicodeUTF8));
1640 
1641  contourAct = new QAction(this);
1642  contourAct->setText(QApplication::translate("Render", "Contour Mode", 0, QApplication::UnicodeUTF8));
1643  contourAct->setCheckable(true);
1644  contourAct->setChecked(false);
1645  contourPolyDataAct = new QAction(this);
1646  contourPolyDataAct->setText(QApplication::translate("Render", "Create Model From Contour", 0, QApplication::UnicodeUTF8));
1647  contourNodePolyDataAct = new QAction(this);
1648  contourNodePolyDataAct->setText(QApplication::translate("Render", "Save Contour", 0, QApplication::UnicodeUTF8));
1649  contourInitAct = new QAction(this);
1650  contourInitAct->setText(QApplication::translate("Render", "Load Contour", 0, QApplication::UnicodeUTF8));
1651 // contourImageAct = new QAction(this);
1652 // contourImageAct->setText(QApplication::translate("Render", "Create Binary Image From Contour", 0, QApplication::UnicodeUTF8));
1653 
1654  contourMenu = new QMenu(this);
1655  contourMenu->setTitle(QApplication::translate("Render", "Contouring", 0, QApplication::UnicodeUTF8));
1656  contourMenu->addAction(contourAct);
1657  contourMenu->addAction(contourPolyDataAct);
1658  contourMenu->addAction(contourNodePolyDataAct);
1659  contourMenu->addAction(contourInitAct);
1660 // contourMenu->addAction(contourImageAct);
1661 
1662  backgroundAct = new QAction(this);
1663  backgroundAct->setText(QApplication::translate("Render", "&White Background", 0, QApplication::UnicodeUTF8));
1664  backgroundAct->setCheckable(true);
1665 
1666  axesAct = new QAction(this);
1667  axesAct->setText(QApplication::translate("Render", "&Axes", 0, QApplication::UnicodeUTF8));
1668  axesAct->setCheckable(true);
1669 
1670  lightingAct = new QAction(this);
1671  lightingAct->setText(QApplication::translate("Render", "&Two-Sided Lighting", 0, QApplication::UnicodeUTF8));
1672  lightingAct->setCheckable(true);
1673  lightingAct->setChecked(true);
1674 
1675  lineAct = new QAction(this);
1676  lineAct->setText(QApplication::translate("Render", "&Draw Line", 0, QApplication::UnicodeUTF8));
1677  lineAct->setCheckable(true);
1678  lineAct->setChecked(false);
1679 
1680  distanceAct = new QAction(this);
1681  distanceAct->setText(QApplication::translate("Render", "&Measure Distance", 0, QApplication::UnicodeUTF8));
1682  distanceAct->setCheckable(true);
1683  distanceAct->setChecked(false);
1684 
1685  biDirectionAct = new QAction(this);
1686  biDirectionAct->setText(QApplication::translate("Render", "&Measure Cross Distance", 0, QApplication::UnicodeUTF8));
1687  biDirectionAct->setCheckable(true);
1688  biDirectionAct->setChecked(false);
1689 
1690  angleAct = new QAction(this);
1691  angleAct->setText(QApplication::translate("Render", "&Measure Angle", 0, QApplication::UnicodeUTF8));
1692  angleAct->setCheckable(true);
1693  angleAct->setChecked(false);
1694 
1695  planeAct = new QAction(this);
1696  planeAct->setText(QApplication::translate("Render", "&Draw Plane", 0, QApplication::UnicodeUTF8));
1697  planeAct->setCheckable(true);
1698  planeAct->setChecked(false);
1699 
1700  boxAct = new QAction(this);
1701  boxAct->setText(QApplication::translate("Render", "&Draw Box/Cuboid", 0, QApplication::UnicodeUTF8));
1702  boxAct->setCheckable(true);
1703  boxAct->setChecked(false);
1704 
1705  sphereAct = new QAction(this);
1706  sphereAct->setText(QApplication::translate("Render", "&Draw Sphere/Circle", 0, QApplication::UnicodeUTF8));
1707  sphereAct->setCheckable(true);
1708  sphereAct->setChecked(false);
1709 
1710  humanAct = new QAction(this);
1711  humanAct->setText(QApplication::translate("Render", "Show Human Orientation", 0, QApplication::UnicodeUTF8));
1712  humanAct->setCheckable(true);
1713  humanAct->setChecked(true);
1714 
1715  textAct = new QAction(this);
1716  textAct->setText(QApplication::translate("Render", "&Insert Text", 0, QApplication::UnicodeUTF8));
1717 
1718  crosshairAct = new QAction(this);
1719  crosshairAct->setText(QApplication::translate("Render", "&Crosshair", 0, QApplication::UnicodeUTF8));
1720  crosshairAct->setCheckable(true);
1721  crosshairAct->setChecked(false);
1722 
1723  windowPropertiesMenu = new QMenu(this);
1724  windowPropertiesMenu->setTitle(QApplication::translate("Render", "Window Properties", 0, QApplication::UnicodeUTF8));
1725  windowPropertiesMenu->addAction(backgroundAct);
1726  windowPropertiesMenu->addAction(axesAct);
1727  windowPropertiesMenu->addAction(lightingAct);
1728  windowPropertiesMenu->addAction(lineAct);
1729  windowPropertiesMenu->addAction(distanceAct);
1731  windowPropertiesMenu->addAction(angleAct);
1732  windowPropertiesMenu->addAction(planeAct);
1733  windowPropertiesMenu->addAction(boxAct);
1734  windowPropertiesMenu->addAction(sphereAct);
1735  windowPropertiesMenu->addAction(textAct);
1736  windowPropertiesMenu->addAction(crosshairAct);
1737 
1738  viewMenu = new QMenu(this);
1739  viewMenu->setTitle("View");
1740  viewXY = new QAction(this);
1741  viewXY->setText(QApplication::translate("Render", "Axial (xy-plane)", 0, QApplication::UnicodeUTF8));
1742  viewXY->setShortcut(tr("Alt+a"));
1743  viewXY->setCheckable(true);
1744  viewXY->setChecked(true);
1745  viewZX = new QAction(this);
1746  viewZX->setText(QApplication::translate("Render", "Coronal (zx-plane)", 0, QApplication::UnicodeUTF8));
1747  viewZX->setShortcut(tr("Alt+c"));
1748  viewZX->setCheckable(true);
1749  viewZY = new QAction(this);
1750  viewZY->setText(QApplication::translate("Render", "Sagittal (zy-plane)", 0, QApplication::UnicodeUTF8));
1751  viewZY->setShortcut(tr("Alt+s"));
1752  viewZY->setCheckable(true);
1753  saveViewAct = new QAction(this);
1754  saveViewAct->setText(QApplication::translate("Render", "Save View", 0, QApplication::UnicodeUTF8));
1755  saveViewAct->setShortcut(tr("Ctrl+Alt+s"));
1756  loadViewAct = new QAction(this);
1757  loadViewAct->setText(QApplication::translate("Render", "Load View", 0, QApplication::UnicodeUTF8));
1758  loadViewAct->setShortcut(tr("Ctrl+Alt+l"));
1759  saveViewFileAct = new QAction(this);
1760  saveViewFileAct->setText(QApplication::translate("Render", "Save View to File", 0, QApplication::UnicodeUTF8));
1761  saveViewFileAct->setShortcut(tr("Shift+Alt+s"));
1762  loadViewFileAct = new QAction(this);
1763  loadViewFileAct->setText(QApplication::translate("Render", "Load View from File", 0, QApplication::UnicodeUTF8));
1764  loadViewFileAct->setShortcut(tr("Shift+Alt+l"));
1765  scaleAct = new QAction(this);
1766  scaleAct->setText(QApplication::translate("Render", "&Scalar Bar", 0, QApplication::UnicodeUTF8));
1767  scaleAct->setCheckable(true);
1768  viewGroup = new QActionGroup(this);
1769  viewGroup->addAction(viewXY);
1770  viewGroup->addAction(viewZX);
1771  viewGroup->addAction(viewZY);
1772 
1773  //Colour map
1774  colourMapMenu = new QMenu(this);
1775  colourMapMenu->setTitle("Colour Maps");
1776  actionDefault = new QAction(this);
1777  actionDefault->setText(QApplication::translate("Render", "None", 0, QApplication::UnicodeUTF8));
1778 // actionDefault->setDisabled(false);
1779  actionDefault->setCheckable(true);
1780  actionDefault->setChecked(true);
1781  actionJet = new LabelledAction("Jet", QPixmap(":resources/cmaps/cm_jet.png"));
1782 // actionJet->setText(QApplication::translate("Render", "Jet", 0, QApplication::UnicodeUTF8));
1783  actionJet->setCheckable(true);
1784  actionJet->setChecked(false);
1785  actionRainbow = new LabelledAction("Rainbow", QPixmap(":resources/cmaps/cm_rainbow.png"));
1786 // actionRainbow->setText(QApplication::translate("Render", "Rainbow", 0, QApplication::UnicodeUTF8));
1787  actionRainbow->setCheckable(true);
1788  actionRainbow->setChecked(false);
1789  actionInvRainbow = new LabelledAction("VTK", QPixmap(":resources/cmaps/cm_vtk.png"), this);
1790 // actionInvRainbow->setText(QApplication::translate("Render", "VTK", 0, QApplication::UnicodeUTF8));
1791  actionInvRainbow->setCheckable(true);
1792  actionInvRainbow->setChecked(false);
1793  actionGray = new LabelledAction("Gray", QPixmap(":resources/cmaps/cm_gray.png"));
1794 // actionGray->setText(QApplication::translate("Render", "Gray", 0, QApplication::UnicodeUTF8));
1795  actionGray->setCheckable(true);
1796  actionGray->setChecked(false);
1797  actionLogGray = new LabelledAction("Gray (Log)", QPixmap(":resources/cmaps/cm_gray.png"));
1798 // actionLogGray->setText(QApplication::translate("Render", "Gray (Log 10)", 0, QApplication::UnicodeUTF8));
1799  actionLogGray->setCheckable(true);
1800  actionLogGray->setChecked(false);
1801  actionSeismic = new LabelledAction("Seismic", QPixmap(":resources/cmaps/cm_seismic.png"));
1802  actionSeismic->setCheckable(true);
1803  actionSeismic->setChecked(false);
1804  actionNIH = new LabelledAction("NIH", QPixmap(":resources/cmaps/cm_nih.png"), this);
1805 // actionNIH->setText(QApplication::translate("Render", "NIH", 0, QApplication::UnicodeUTF8));
1806  actionNIH->setCheckable(true);
1807  actionNIH->setChecked(false);
1808  actionNIH_FIRE = new LabelledAction("NIH Fire", QPixmap(":resources/cmaps/cm_nih_fire.png"), this);
1809 // actionNIH_FIRE->setText(QApplication::translate("Render", "NIH Fire", 0, QApplication::UnicodeUTF8));
1810  actionNIH_FIRE->setCheckable(true);
1811  actionNIH_FIRE->setChecked(false);
1812  actionAAL = new LabelledAction("AAL", QPixmap(":resources/cmaps/cm_aal.png"), this);
1813 // actionAAL->setText(QApplication::translate("Render", "AAL", 0, QApplication::UnicodeUTF8));
1814  actionAAL->setCheckable(true);
1815  actionAAL->setChecked(false);
1816  actionFS = new LabelledAction("FreeSurfer", QPixmap(":resources/cmaps/cm_fs.png"), this);
1817 // actionFS->setText(QApplication::translate("Render", "FreeSurfer", 0, QApplication::UnicodeUTF8));
1818  actionFS->setCheckable(true);
1819  actionFS->setChecked(false);
1820  actionHOT = new LabelledAction("HOT", QPixmap(":resources/cmaps/cm_hot.png"), this);
1821 // actionHOT->setText(QApplication::translate("Render", "HOT", 0, QApplication::UnicodeUTF8));
1822 // actionHOT->setIcon(QIcon(":resources/cmaps/cm_hot.png"));
1823  actionHOT->setCheckable(true);
1824  actionHOT->setChecked(false);
1825  actionCOOL = new LabelledAction("COOL", QPixmap(":resources/cmaps/cm_cool.png"), this);
1826 // actionCOOL->setText(QApplication::translate("Render", "COOL", 0, QApplication::UnicodeUTF8));
1827  actionCOOL->setCheckable(true);
1828  actionCOOL->setChecked(false);
1829  actionCOOLWARM = new LabelledAction("COOL-WARM", QPixmap(":resources/cmaps/cm_coolwarm.png"), this);
1830 // actionCOOLWARM->setText(QApplication::translate("Render", "COOL-WARM", 0, QApplication::UnicodeUTF8));
1831 // actionCOOLWARM->setIcon(QIcon(":resources/cmaps/cm_coolwarm.png"));
1832  actionCOOLWARM->setCheckable(true);
1833  actionCOOLWARM->setChecked(false);
1834  actionKnee = new LabelledAction("Knee", QPixmap(":resources/cmaps/cm_knee.png"), this);
1835 // actionKnee->setText(QApplication::translate("Render", "Knee", 0, QApplication::UnicodeUTF8));
1836  actionKnee->setCheckable(true);
1837  actionKnee->setChecked(false);
1838  actionBone = new LabelledAction("Bone", QPixmap(":resources/cmaps/cm_bone.png"), this);
1839 // actionBone->setText(QApplication::translate("Render", "Bone", 0, QApplication::UnicodeUTF8));
1840 // actionBone->setIcon(QIcon(":resources/cmaps/cm_bone.png"));
1841  actionBone->setCheckable(true);
1842  actionBone->setChecked(false);
1843  actionSpectral = new LabelledAction("Spectral", QPixmap(":resources/cmaps/cm_Spectral.png"), this);
1844 // actionSpectral->setText(QApplication::translate("Render", "Spectral", 0, QApplication::UnicodeUTF8));
1845 // actionSpectral->setIcon(QIcon(":resources/cmaps/cm_Spectral.png"));
1846  actionSpectral->setCheckable(true);
1847  actionSpectral->setChecked(false);
1848  actionGNUPlot = new LabelledAction("GNUPlot", QPixmap(":resources/cmaps/cm_gnuplot.png"), this);
1849 // actionGNUPlot->setText(QApplication::translate("Render", "GNUPlot", 0, QApplication::UnicodeUTF8));
1850 // actionGNUPlot->setIcon(QIcon(":resources/cmaps/cm_gnuplot.png"));
1851  actionGNUPlot->setCheckable(true);
1852  actionGNUPlot->setChecked(false);
1853  actionCubeHelix = new LabelledAction("CubeHelix", QPixmap(":resources/cmaps/cm_cubehelix.png"), this);
1854 // actionCubeHelix->setText(QApplication::translate("Render", "CubeHelix", 0, QApplication::UnicodeUTF8));
1855 // actionCubeHelix->setIcon(QIcon(":resources/cmaps/cm_gnuplot.png"));
1856  actionCubeHelix->setCheckable(true);
1857  actionCubeHelix->setChecked(false);
1858  actionHSV = new LabelledAction("HSV", QPixmap(":resources/cmaps/cm_hsv.png"), this);
1859  actionHSV->setCheckable(true);
1860  actionHSV->setChecked(false);
1861  mapGroup = new QActionGroup(this);
1862  mapGroup->addAction(actionDefault);
1863  mapGroup->addAction(actionJet);
1864  mapGroup->addAction(actionRainbow);
1865  mapGroup->addAction(actionInvRainbow);
1866  mapGroup->addAction(actionGray);
1867  mapGroup->addAction(actionLogGray);
1868  mapGroup->addAction(actionSeismic);
1869  mapGroup->addAction(actionNIH);
1870  mapGroup->addAction(actionNIH_FIRE);
1871  mapGroup->addAction(actionAAL);
1872  mapGroup->addAction(actionFS);
1873  mapGroup->addAction(actionHOT);
1874  mapGroup->addAction(actionCOOL);
1875  mapGroup->addAction(actionCOOLWARM);
1876  mapGroup->addAction(actionKnee);
1877  mapGroup->addAction(actionBone);
1878  mapGroup->addAction(actionSpectral);
1879  mapGroup->addAction(actionGNUPlot);
1880  colourMapsMenu();
1881 
1882  refreshAct = new QAction(this);
1883  refreshAct->setText(QApplication::translate("Render", "&Refresh", 0, QApplication::UnicodeUTF8));
1884  refreshAct->setShortcut(tr("F5"));
1885  resetAct = new QAction(this);
1886  resetAct->setText(QApplication::translate("Render", "Reset", 0, QApplication::UnicodeUTF8));
1887  resetAct->setIcon(QIcon(":/resources/toolbar/refresh.png"));
1888  resetAct->setShortcut(tr("F7"));
1889 }
1890 
1892 {
1893  //Re-direct mouse events
1894  connect(this, SIGNAL(mouseEvent(QMouseEvent*)), this, SLOT(userEvent(QMouseEvent*)));
1895 
1896  //Stop VTK intercepting right click events
1897  /*Connector->Connect(QVTKWidget::GetInteractor(),
1898  vtkCommand::RightButtonPressEvent,
1899  this,
1900  SLOT( consumeVTKEvent(vtkObject*, unsigned long, void*, void*, vtkCommand*) ),
1901  NULL, 1.0); //High Priority
1902  Connector->Connect(QVTKWidget::GetInteractor(),
1903  vtkCommand::RightButtonReleaseEvent,
1904  this,
1905  SLOT( consumeVTKEvent(vtkObject*, unsigned long, void*, void*, vtkCommand*) ),
1906  NULL, 1.0); //High Priority*/
1907 
1908  connect(contourAct, SIGNAL(triggered()), this, SLOT(contour()));
1909  connect(contourPolyDataAct, SIGNAL(triggered()), this, SLOT(contourAsPolyData()));
1910  connect(contourNodePolyDataAct, SIGNAL(triggered()), this, SLOT(contourAsNodePolyData()));
1911  connect(contourInitAct, SIGNAL(triggered()), this, SLOT(contourInitFromPolyData()));
1912 // connect(contourImageAct, SIGNAL(triggered()), this, SLOT(contourAsBinaryImage()));
1913  connect(backgroundAct, SIGNAL(triggered()), this, SLOT(background()));
1914  connect(axesAct, SIGNAL(triggered()), this, SLOT(axesDisplay()));
1915  connect(lightingAct, SIGNAL(triggered()), this, SLOT(lighting()));
1916  connect(lineAct, SIGNAL(triggered()), this, SLOT(refresh()));
1917  connect(distanceAct, SIGNAL(triggered()), this, SLOT(refresh()));
1918  connect(biDirectionAct, SIGNAL(triggered()), this, SLOT(refresh()));
1919  connect(angleAct, SIGNAL(triggered()), this, SLOT(refresh()));
1920  connect(planeAct, SIGNAL(triggered()), this, SLOT(refresh()));
1921  connect(boxAct, SIGNAL(triggered()), this, SLOT(refresh()));
1922  connect(sphereAct, SIGNAL(triggered()), this, SLOT(refresh()));
1923  connect(humanAct, SIGNAL(triggered()), this, SLOT(refresh()));
1924  connect(textAct, SIGNAL(triggered()), this, SLOT(textDisplay()));
1925  connect(crosshairAct, SIGNAL(triggered()), this, SLOT(crosshair()));
1926  connect(viewXY, SIGNAL(triggered()), this, SLOT(viewToXYPlane()));
1927  connect(viewZX, SIGNAL(triggered()), this, SLOT(viewToZXPlane()));
1928  connect(viewZY, SIGNAL(triggered()), this, SLOT(viewToZYPlane()));
1929  connect(actionJet, SIGNAL(triggered()), this, SLOT(colourMapToJet()));
1930  connect(actionRainbow, SIGNAL(triggered()), this, SLOT(colourMapToRainbow()));
1931  connect(actionInvRainbow, SIGNAL(triggered()), this, SLOT(colourMapToVTK()));
1932  connect(actionGray, SIGNAL(triggered()), this, SLOT(colourMapToGray()));
1933  connect(actionLogGray, SIGNAL(triggered()), this, SLOT(colourMapToLogGray()));
1934  connect(actionSeismic, SIGNAL(triggered()), this, SLOT(colourMapToSeismic()));
1935  connect(actionNIH, SIGNAL(triggered()), this, SLOT(colourMapToNIH()));
1936  connect(actionNIH_FIRE, SIGNAL(triggered()), this, SLOT(colourMapToNIH_Fire()));
1937  connect(actionAAL, SIGNAL(triggered()), this, SLOT(colourMapToAAL()));
1938  connect(actionFS, SIGNAL(triggered()), this, SLOT(colourMapToFS()));
1939  connect(actionHOT, SIGNAL(triggered()), this, SLOT(colourMapToHOT()));
1940  connect(actionCOOL, SIGNAL(triggered()), this, SLOT(colourMapToCOOL()));
1941  connect(actionCOOLWARM, SIGNAL(triggered()), this, SLOT(colourMapToCOOLWARM()));
1942  connect(actionKnee, SIGNAL(triggered()), this, SLOT(colourMapToKnee()));
1943  connect(actionBone, SIGNAL(triggered()), this, SLOT(colourMapToBone()));
1944  connect(actionSpectral, SIGNAL(triggered()), this, SLOT(colourMapToSpectral()));
1945  connect(actionGNUPlot, SIGNAL(triggered()), this, SLOT(colourMapToGNUPlot()));
1946  connect(actionCubeHelix, SIGNAL(triggered()), this, SLOT(colourMapToCubeHelix()));
1947  connect(actionHSV, SIGNAL(triggered()), this, SLOT(colourMapToHSV()));
1948  connect(saveViewAct, SIGNAL(triggered()), this, SLOT(saveView()));
1949  connect(loadViewAct, SIGNAL(triggered()), this, SLOT(loadView()));
1950  connect(saveViewFileAct, SIGNAL(triggered()), this, SLOT(saveViewFile()));
1951  connect(loadViewFileAct, SIGNAL(triggered()), this, SLOT(loadViewFile()));
1952  connect(scaleAct, SIGNAL(triggered()), this, SLOT(scaleDisplay()));
1953  connect(refreshAct, SIGNAL(triggered()), this, SLOT(refresh()));
1954  connect(resetAct, SIGNAL(triggered()), this, SLOT(reset()));
1955 }
1956 
1957 void milxQtRenderWindow::contextMenuEvent(QContextMenuEvent *currentEvent)
1958 {
1960 
1961  contextMenu->exec(currentEvent->globalPos());
1962 }
1963 
1965 {
1966  colourMapMenu->addAction(actionDefault);
1967  colourMapMenu->addAction(actionJet);
1968  colourMapMenu->addAction(actionRainbow);
1969  colourMapMenu->addAction(actionGray);
1970  colourMapMenu->addAction(actionLogGray);
1971  colourMapMenu->addAction(actionSeismic);
1972  colourMapMenu->addAction(actionSpectral);
1973  colourMapMenu->addAction(actionGNUPlot);
1974  colourMapMenu->addAction(actionBone);
1975  colourMapMenu->addAction(actionHOT);
1976  colourMapMenu->addAction(actionCOOL);
1977  colourMapMenu->addAction(actionCOOLWARM);
1978  colourMapMenu->addAction(actionCubeHelix);
1979  colourMapMenu->addAction(actionHSV);
1980  colourMapMenu->addAction(actionInvRainbow);
1981  colourMapMenu->addAction(actionNIH);
1982  colourMapMenu->addAction(actionNIH_FIRE);
1983  colourMapMenu->addAction(actionAAL);
1984  colourMapMenu->addAction(actionFS);
1985  colourMapMenu->addAction(actionKnee);
1986 
1987  return colourMapMenu;
1988 }
1989 
1990 //Drag members
1991 //Drop members
1992 void milxQtRenderWindow::dragLeaveEvent(QDragLeaveEvent *event)
1993 {
1994  event->accept();
1995 }
1996 
1997 void milxQtRenderWindow::dragMoveEvent(QDragMoveEvent *event)
1998 {
1999  event->acceptProposedAction();
2000 }
2001 
2002 void milxQtRenderWindow::dragEnterEvent(QDragEnterEvent *currentEvent)
2003 {
2004  if(currentEvent->mimeData()->hasFormat("text/uri-list") || currentEvent->mimeData()->hasFormat("text/plain"))
2005  currentEvent->acceptProposedAction();
2006 }
2007 
2009 {
2010  QDrag *drag = new QDrag(this);
2011  QMimeData *mimeData = new QMimeData;
2012 
2013  QList<QUrl> urls;
2014  urls.append( QUrl("file://localhost/" + getName()) );
2015 
2016  mimeData->setUrls(urls);
2017  drag->setMimeData(mimeData);
2018 
2019  drag->exec(Qt::CopyAction | Qt::MoveAction | Qt::LinkAction, Qt::CopyAction);
2020 }
2021 
2022 void milxQtRenderWindow::dropEvent(QDropEvent *currentEvent)
2023 {
2024  if(currentEvent->source() == this) //disallow self drops
2025  return;
2026 
2027  milxQtRenderWindow *sourceWindow = qobject_cast<milxQtRenderWindow *>(currentEvent->source());
2028 
2029  QList<QUrl> urlsList = currentEvent->mimeData()->urls();
2030  QString tmp, typeString = currentEvent->mimeData()->text();
2031 
2032  for(int j = 0; j < urlsList.size(); j ++)
2033  {
2034  if(urlsList[j].isValid())
2035  {
2036  printInfo("Dropped Path into Render Window: " + urlsList[j].path());
2037 
2038  if(sourceWindow)
2039  {
2040  importFrom(sourceWindow);
2041  }
2042  else
2043  {
2044  printError("Data type unsupported. Passing on drop... ");
2045  currentEvent->ignore(); //dont accept drop
2046  }
2047  }
2048  }
2049 
2050  currentEvent->acceptProposedAction();
2051 }
2052 
2053 void milxQtRenderWindow::setupHumanGlyph(vtkSmartPointer<vtkMatrix4x4> mat)
2054 {
2055  vtkSmartPointer<vtkPolyData> human;
2056  openModelUsingQt(":/resources/human.obj", human); //needs to be done usingQt method to access model as a resource
2057 
2058  vtkSmartPointer<vtkPolyData> humanTransformed;
2059  if(mat)
2060  {
2061  vtkSmartPointer<vtkTransform> transf = vtkSmartPointer<vtkTransform>::New();
2062  transf->SetMatrix(mat);
2063 
2064  vtkSmartPointer<vtkTransformPolyDataFilter> transformer = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
2065  #if VTK_MAJOR_VERSION <= 5
2066  transformer->SetInput(human);
2067  #else
2068  transformer->SetInputData(human);
2069  #endif
2070  transformer->SetTransform(transf);
2071  transformer->Update();
2072 
2073  vtkSmartPointer<vtkPolyDataNormals> normalsHuman = vtkSmartPointer<vtkPolyDataNormals>::New();
2074  #if VTK_MAJOR_VERSION <= 5
2075  normalsHuman->SetInput(transformer->GetOutput());
2076  #else
2077  normalsHuman->SetInputData(transformer->GetOutput());
2078  #endif
2079  normalsHuman->Update();
2080 
2081  humanTransformed = normalsHuman->GetOutput();
2082  }
2083  else
2084  humanTransformed = human;
2085 
2086  vtkSmartPointer<vtkPropAssembly> propAssembly = vtkSmartPointer<vtkPropAssembly>::New();
2087  orientAxes = vtkSmartPointer<vtkAxesActor>::New();
2088 
2089  if(orientationAxes)
2090  {
2091  orientAxes->GetXAxisCaptionActor2D()->GetCaptionTextProperty()->ShadowOff();
2092  orientAxes->GetXAxisCaptionActor2D()->GetCaptionTextProperty()->SetFontSize(14);
2093  orientAxes->GetXAxisCaptionActor2D()->GetTextActor()->SetTextScaleModeToNone();
2094  orientAxes->GetYAxisCaptionActor2D()->GetCaptionTextProperty()->ShadowOff();
2095  orientAxes->GetYAxisCaptionActor2D()->GetCaptionTextProperty()->SetFontSize(14);
2096  orientAxes->GetYAxisCaptionActor2D()->GetTextActor()->SetTextScaleModeToNone();
2097  orientAxes->GetZAxisCaptionActor2D()->GetCaptionTextProperty()->ShadowOff();
2098  orientAxes->GetZAxisCaptionActor2D()->GetCaptionTextProperty()->SetFontSize(14);
2099  orientAxes->GetZAxisCaptionActor2D()->GetTextActor()->SetTextScaleModeToNone();
2100  orientAxes->SetXAxisLabelText("Left");
2101  orientAxes->SetYAxisLabelText("P");
2102  orientAxes->SetZAxisLabelText("S");
2103 
2104  if(mat)
2105  orientAxes->SetUserMatrix(mat);
2106 
2107  propAssembly->AddPart(orientAxes);
2108  }
2109 
2110  vtkSmartPointer<vtkPolyDataMapper> humanMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
2111  #if VTK_MAJOR_VERSION <= 5
2112  humanMapper->SetInput(humanTransformed);
2113  #else
2114  humanMapper->SetInputData(humanTransformed);
2115  #endif
2116  vtkSmartPointer<vtkActor> humanActor = vtkSmartPointer<vtkActor>::New();
2117  humanActor->SetMapper(humanMapper);
2118  humanActor->GetProperty()->SetInterpolationToPhong();
2119 // humanActor->GetProperty()->SetColor(235/255.0, 180/255.0, 173/255.0); //skin
2120  humanActor->GetProperty()->SetColor(60/255.0, 232/255.0, 30/255.0); //Varian Eclipse green
2121  propAssembly->AddPart(humanActor);
2122  humanGlyph = vtkSmartPointer<vtkOrientationMarkerWidget>::New();
2123  humanGlyph->SetOutlineColor(0.0, 0, 0.0);
2124  humanGlyph->SetOrientationMarker(propAssembly);
2125  humanGlyph->SetInteractor(QVTKWidget::GetInteractor());
2126  humanGlyph->SetViewport(0.0, 0.0, 0.3, 0.3);
2127  humanGlyph->SetDefaultRenderer(renderer);
2128 }
QAction * scaleAct
Action for the scale bar of the display.
void printWarning(QString msg)
Warning message wrapper for console.
virtual void createMenu(QMenu *menu)
Create the menu for the data in this object. Used for context menu and file menus.
void disableAxes()
Disables the axes display.
int defaultView
Default view for data (default is axial)
virtual void colourMapToSpectral(double minRange=0.0, double maxRange=0.0)
Change the colour map to Spectral.
bool logScale
Using custom scalar bar?
vtkSmartPointer< vtkAxesActor > axes
Axes for the model.
void printError(QString msg)
Error message wrapper for console.
void dragEnterEvent(QDragEnterEvent *event)
Part of the Drag and Drop feature members. Tells what drags to accept.
void RemoveActor(vtkSmartPointer< vtkProp > actor)
Remove the VTK actor from this window.
LabelledAction * actionGNUPlot
GNUPlot colours.
virtual void colourMapToVTK(double minRange=0.0, double maxRange=0.0)
Change the colour map to inverse of default VTK.
QAction * saveViewFileAct
Save camera view to file.
LabelledAction * actionHSV
Cube Helix colours.
QMenu * viewMenu
Context Menu.
vtkSmartPointer< vtkBoxWidget2 > boxWidget
Used for measuring angles.
QAction * lightingAct
Action for two-sided lighting of the display.
int currentView
Current view for data.
QActionGroup * windowActionGroup
used for the custom menu
vtkActorCollection * GetActors()
Get all the actors in the render window.
QMenu * colourMapsMenu()
Return the colourmaps menu with the milxQtRenderWindow class ordering. This is for the benefit of der...
void enableAxes(float xScale=1.0, float yScale=1.0, float zScale=1.0)
Enable axes display with each arrow for dimension scaled as provided.
vtkSmartPointer< vtkContourWidget > contourWidget
contour interaction
vtkSmartPointer< vtkRenderer > renderer
Renderer for the data.
void AddActor(vtkSmartPointer< vtkProp > actor)
Add a VTK actor to this window.
QAction * actionNIH_FIRE
NIH_FIRE colours.
This class represents the MILX Qt Render Window Display object using QVTK.
vtkSmartPointer< vtkAngleWidget > angleWidget
Used for measuring angles.
void updateQtEvents()
Update the Qt events, used to keep UI responsive.
Definition: milxQtWindow.h:213
virtual QString strippedNamePrefix()
Returns the stripped (path removed) name of the data with "Generic" prefix.
Definition: milxQtWindow.h:98
vtkSmartPointer< vtkLookupTable > lookupTable
Lookup table for the shapes/images, base class is used to allow references to different look up table...
virtual void updateTextActor(vtkObject *obj, unsigned long, void *client_data, void *, vtkCommand *command)
Update any text actors in display to current slice.
QAction * viewZY
Change view to zy-plane (Coronal)
QAction * actionNIH
NIH colours.
void createConnections()
Create the connections for context menu etc.
bool loaded
Loaded Image from file?
bool axesBefore
Axes displayed?
QAction * actionLogGray
Logarithmic Gray colours.
vtkSmartPointer< vtkBiDimensionalWidget > biDirectionWidget
Used for measuring cross distances.
vtkSmartPointer< vtkMatrix4x4 > transformMatrix
Transform matrix for actor(s)
QAction * actionKnee
Knee colours.
QMenu * contextMenu
Context Menu.
Definition: milxQtWindow.h:250
QAction * axesAct
Action for axes of the display.
virtual vtkDataSet * GetDataSet()
Get the data, Implement in derived class that uses data derived from vtkDataSet, like vtkPolyData or ...
QAction * boxAct
Action for box drawing display.
vtkSmartPointer< vtkOrientationMarkerWidget > humanGlyph
Glyph for showing equivalent view on human.
QAction * crosshairAct
Action for crosshair.
virtual void contour()
Draw contour interactively.
virtual void updateLookupTable()
Implement this into your derived class to ensure the new colourmap is passed on to your viewing data ...
virtual void viewToZXPlane()
Change view to zx-plane.
void modified(vtkSmartPointer< vtkImageActor >)
Emit signal to allow updating of image actors if present.
LabelledAction * actionCubeHelix
Cube Helix colours.
This class represents the MILX Qt Window Display object using QVTK.
Definition: milxQtWindow.h:40
virtual void colourMapToBone(double minRange=0.0, double maxRange=0.0)
Change the colour map to Bone.
virtual void colourMapToFS(double minRange=0.0, double maxRange=0.0)
Change the colour map to FS (FreeSurfer)
QAction * humanAct
Show human view orientation glyph?
QAction * actionInvRainbow
Inv Default colours.
QList< QMenu * > menusToAdd
Context Menu&#39;s to add.
Definition: milxQtWindow.h:254
static bool OpenModel(const std::string filename, vtkSmartPointer< vtkPolyData > &data)
Opens a model file, which can be a VTK XML, Legacy VTK PolyData File (i.e. either a *...
Definition: milxFile.cxx:488
virtual void colourMapToSeismic(double minRange=0.0, double maxRange=0.0)
Change the colour map to Seismic.
QAction * backgroundAct
Action for axes of the display.
LabelledAction * actionSpectral
Spectral colours.
vtkSmartPointer< vtkDistanceWidget > distanceWidget
Used for measuring distances.
vtkSmartPointer< vtkLineWidget2 > lineWidget
Used for drawing lines.
QActionGroup * viewGroup
Grouping for check boxes.
void printDebug(QString msg)
Debug message wrapper for console.
QAction * contourPolyDataAct
Save contour surface points as polydata.
QAction * lineAct
Action for distance measuring display.
void addModelActor(vtkSmartPointer< vtkActor > mdlActor)
Directly add model actor to generic view.
virtual void disableCrosshair()
Restores the mouse pointer to default.
QAction * actionRainbow
Default colours.
QAction * actionDefault
Default colours.
vtkSmartPointer< vtkLookupTable > GetOutput()
Get the colourmap set.
QAction * contourAct
Action for contouring surface points using Dijkstras algorithm.
bool orientationAxes
Display orientation (posterior etc.) axes?
QList< ImageActorItem > imageActors
Images actors being displayed in model view.
void Render()
Force Render or Update of the display.
LabelledAction * actionBone
Spectral colours.
void orientDisplay()
Toggles orientation marker.
void enableUpdates(QStatusBar *bar)
Enables the update of coordinates to the status bar provided directly. Update is done on mouse moveme...
QAction * actionJet
Jet colours.
virtual void colourMapToAAL(double minRange=0.0, double maxRange=0.0)
Change the colour map to AAL.
virtual void colourMapToNIH(double minRange=0.0, double maxRange=0.0)
Change the colour map to NIH.
void contourInitFromPolyData(QString filename="")
Load contour from polydata/model.
int orientationView
view orientation standard
virtual void updateCoords(vtkObject *obj)
Picks the coordinates and pixel value from the current mouse position in the window.
void textDisplay()
Toggles text in display.
QList< QAction * > actionsToAppend
Context actions to append.
Definition: milxQtWindow.h:252
QAction * contourNodePolyDataAct
Save contour surface nodes as polydata.
void addImageActor(vtkSmartPointer< vtkImageActor > imgActor, vtkMatrix4x4 *transformMatrix=NULL)
Directly add image actor to generic view.
QAction * refreshAct
Action for refreshing the display.
vtkSmartPointer< vtkAxesActor > orientAxes
Orientation (posterior etc.) axes for the orientation marker.
QAction * textAct
Action for angle measuring display.
QAction * contourInitAct
Load contour surface points from polydata.
bool scaleBefore
scale displayed?
bool contextMenuEnabled
Display orientation (posterior etc.) axes?
void enableActionBasedOnView()
Enables the view actions corresponding to current view set.
void contextMenuEvent(QContextMenuEvent *event)
The context menu setup member.
void contourAsPolyData()
Save contour as polydata/model. This saves all intermediate points, not just what the user places...
QMenu * contourMenu
Contour Menu.
virtual void colourMapToRainbow(double minRange=0.0, double maxRange=0.0)
Change the colour map to default VTK which is rainbow.
void createActions()
Create the actions for context menu etc.
void reset()
Reset the rendering, camera and windowing.
void dropEvent(QDropEvent *event)
Part of the Drag and Drop feature members. Opens the dropped files.
QAction * resetAct
Action for refreshing the display.
void contourAsNodePolyData()
Save contour as polydata/model. This only saves the points the user has placed.
QMenu * colourMapMenu
Colour map menu.
virtual void colourMapToCubeHelix(double minRange=0.0, double maxRange=0.0)
Change the colour map to CubeHelix.
void generateRender()
Generate the render so it is ready for display. Should be called before showing the window...
LabelledAction * actionHOT
HOT colours.
virtual void scaleDisplay(const bool forceDisplay=false)
Toggles the scale bar display.
virtual void disableScale()
Disables the scale bar display.
virtual void customOperation()
Custom operation, data dependent for viewing in unified environment. By default, this allows importin...
void linkProgressEventOf(vtkObject *obj)
Link the progress of filters etc to keep the UI responsive.
virtual void colourMapToLogGray(double minRange=0.0, double maxRange=0.0)
Change the colour map to Logarithmic (base 10) Gray.
void dragLeaveEvent(QDragLeaveEvent *event)
Part of the Drag and Drop feature members. Accepts drags.
QAction * saveViewAct
Save camera view.
virtual void enableCrosshair()
Enables the mouse pointer as a crosshair instead. Scene must be rendered before calling.
QAction * viewXY
Change view to xy-plane (Axial)
virtual void colourMapToCOOLWARM(double minRange=0.0, double maxRange=0.0)
Change the colour map to COOL.
QActionGroup * mapGroup
Grouping for check boxes.
void modelAvailable(vtkPolyData *, QString)
Send signal that an surface etc. is available for showing.
virtual void colourMapToGNUPlot(double minRange=0.0, double maxRange=0.0)
Change the colour map to GNUPlot.
QString getName()
Returns the name of the data.
Definition: milxQtWindow.h:67
vtkSmartPointer< vtkPlaneWidget > planeWidget
Used for drawing planes.
void lighting()
Toggles two sided lighting in display.
vtkSmartPointer< vtkCamera > camera
camera for the view
void removeImageActor(vtkSmartPointer< vtkImageActor > imgActor)
Directly remove image actor from generic view.
LabelledAction * actionGray
Gray colours.
QAction * actionCOOL
COOL colours.
virtual void colourMapToGray(double minRange=0.0, double maxRange=0.0)
Change the colour map to Gray.
bool rendered
Scene as been setup for rendering? (by generateRender())
virtual void viewToZYPlane()
Change view to zy-plane.
QList< QAction * > actionsToAdd
Context actions to add.
Definition: milxQtWindow.h:251
void setupHumanGlyph(vtkSmartPointer< vtkMatrix4x4 > mat=NULL)
Setup the human orientation glyph even if some transform if present between glyph and view...
vtkSmartPointer< vtkSphereWidget2 > sphereWidget
Used for measuring angles.
QAction * viewZX
Change view to zx-plane (Sagittal)
bool openModelUsingQt(const QString filename, vtkSmartPointer< vtkPolyData > &data)
Opens a model file using Qt file objects, which can be a Wavefront Object file (*.obj) only. This member is intended to be used with the Qt resource system.
LabelledAction * actionCOOLWARM
COOL colours.
void setView(int viewMode)
Change view to view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
void axesDisplay()
Toggles the axes display.
LabelledAction * actionSeismic
Gray2 colours.
virtual void colourMapToHOT(double minRange=0.0, double maxRange=0.0)
Change the colour map to HOT.
vtkSmartPointer< vtkMatrix4x4 > getTransformMatrix()
Internal transform matrix used to transform actors appropriately for direction and coordinate systems...
QAction * distanceAct
Action for distance measuring display.
QList< vtkSmartPointer< vtkTextWidget > > textWidgets
Used for displaying movable texts in render window.
virtual ~milxQtRenderWindow()
The standard destructor.
virtual void colourMapToKnee(double minRange=0.0, double maxRange=0.0)
Change the colour map to Knee.
vtkSmartPointer< vtkSphereRepresentation > sphereRep
Sphere for widgets.
virtual void viewToXYPlane()
Change view to xy-plane.
virtual void colourMapToNIH_Fire(double minRange=0.0, double maxRange=0.0)
Change the colour map to NIH Fire.
QAction * biDirectionAct
Action for cross distance measuring display.
QList< vtkSmartPointer< vtkTextActor > > textActors
text actors for text widgets
milxQtRenderWindow(QWidget *theParent=0, bool contextSystem=true)
The standard constructor.
void dragMoveEvent(QDragMoveEvent *event)
Part of the Drag and Drop feature members. Accepts drags.
virtual vtkImageActor * GetImageActor()
Get the image actors, Implement in derived class that uses images.
void refresh()
Refresh the display of the model including widgets. Camera remains as is.
void crosshair()
Toggles corsshair.
vtkSmartPointer< vtkRenderWindow > renderWindow
Render Window used if no other set, only for deletion, access through QVTKWidget members.
QAction * actionFS
FS colours.
void printInfo(QString msg)
Info message wrapper for console.
virtual void colourMapToCOOL(double minRange=0.0, double maxRange=0.0)
Change the colour map to COOL.
bool useDefaultView
Using log scalar map?
QAction * actionAAL
AAL colours.
vtkSmartPointer< vtkEventQtSlotConnect > Connector
VTK Events to slots convertor.
void addActor(vtkSmartPointer< vtkActor > imgActor, vtkMatrix4x4 *transformMatrix=NULL)
Directly add actor to generic view with transform matrix.
vtkSmartPointer< vtkScalarBarWidget > scalarBar
Scalar Bar Widget for the display.
QMenu * windowPropertiesMenu
Context Menu.
virtual void colourMapToHSV(double minRange=0.0, double maxRange=0.0)
Change the colour map to HSV.
vtkRenderer * GetRenderer()
Returns the VTK Renderer object.
virtual void updateImageActor(vtkObject *obj, unsigned long, void *client_data, void *, vtkCommand *command)
Update any image actors in display to current slice when slice number changes.
virtual void background(bool white=false)
Changes background to white.
QAction * planeAct
Action for drawing planes.
QAction * angleAct
Action for angle measuring display.
void importFrom(milxQtRenderWindow *windowToImportFrom)
Import actors/scene directly from another renderwindow.
void contextMenuSystem(bool context)
Disable/enable context menu system, should be on by default otherwise VTK will steal all right click ...
QStatusBar * updateBar
Pointer to bar, not allocated or deleted. To be passed to only.
QList< QMenu * > menusToAppend
Context Menu&#39;s to append.
Definition: milxQtWindow.h:255
Represents a the various colour maps available for VTK scalars etc. Default: NIH. ...
Definition: milxColourMap.h:49
QAction * loadViewAct
Load camera view.
void removeModelActor(vtkSmartPointer< vtkActor > mdlActor)
Directly remove model actor from generic view.
vtkSmartPointer< vtkPointPicker > dataPicker
For determining coordinates and points from the window.
void disableOrient()
Disables orientation marker.
virtual void SetupWidgets(vtkRenderWindowInteractor *interactor)
Update the interactor so that the widgets are usable. Call this if you change the render window or in...
QAction * sphereAct
Action for sphere annotate display.
void mouseDoubleClickEvent(QMouseEvent *event)
Part of the Drag and Drop feature members. Triggers the dragging on double click. ...
void loadView(QString filename="")
Saves the camera details to internal variables that can be restore anytime with loadView().
virtual void colourMapToJet(double minRange=0.0, double maxRange=0.0)
Change the colour map to Jet.
QAction * loadViewFileAct
Load camera view to file.