18 #ifndef MILXQTRENDERWINDOW_H 19 #define MILXQTRENDERWINDOW_H 21 #include "milxQtWindow.h" 23 #include <vtkSmartPointer.h> 24 #include <vtkRenderWindow.h> 25 #include <vtkRenderer.h> 26 #include <vtkCamera.h> 28 #include <vtkActor2D.h> 29 #include <vtkActorCollection.h> 30 #include <vtkAxesActor.h> 31 #include <vtkLookupTable.h> 32 #include <vtkImageData.h> 33 #include <vtkImageActor.h> 34 #include <vtkEventQtSlotConnect.h> 36 #include <vtkScalarBarActor.h> 38 #include <vtkScalarBarWidget.h> 39 #include <vtkContourWidget.h> 40 #include <vtkLineWidget2.h> 41 #include <vtkDistanceWidget.h> 42 #include <vtkBiDimensionalWidget.h> 43 #include <vtkAngleWidget.h> 44 #include <vtkPlaneWidget.h> 45 #include <vtkBoxWidget2.h> 46 #include <vtkSphereRepresentation.h> 47 #include <vtkSphereWidget2.h> 48 #include <vtkOrientationMarkerWidget.h> 49 #include <vtkTextWidget.h> 52 enum ViewType { AXIAL = 0, CORONAL = 1, SAGITTAL = 2 };
53 enum ViewerType { SINGLE = 0, SCANNER = 1};
54 enum OrientationType { RADIOLOGICAL = 0, NEUROLOGICAL = 1};
59 vtkSmartPointer<vtkImageActor> parentActor;
60 vtkSmartPointer<vtkImageActor> imageActor;
65 LabelledAction (
const QString& title, QPixmap pix, QWidget *theParent = 0) :
66 QWidgetAction(theParent) {
67 pWidget =
new QWidget(theParent);
68 pLayout =
new QHBoxLayout();
69 pLabel =
new QLabel(title);
70 pPixmapLabel =
new QLabel(title);
71 pPixmapLabel->setPixmap(pix);
72 pPixmapLabel->setScaledContents(
true);
73 pLayout->addWidget (pPixmapLabel);
74 pLayout->addWidget (pLabel);
75 pWidget->setLayout (pLayout);
76 setDefaultWidget(pWidget);
82 QLabel* pixmapLabel() {
150 void contextMenuSystem(
bool context);
156 inline void AddActor(vtkSmartPointer<vtkProp> actor)
158 renderer->AddActor(actor);
166 renderer->AddVolume(actor);
174 renderer->AddActor2D(actor);
181 inline void SetActor(vtkSmartPointer<vtkProp> actor)
183 renderer->AddActor(actor);
191 renderer->AddActor2D(actor);
199 renderer->GradientBackgroundOff();
200 renderer->SetBackground(red, green, blue);
208 QVTKWidget::GetRenderWindow()->SetSize(width, height);
209 int *winSize = QVTKWidget::GetRenderWindow()->GetSize();
210 QVTKWidget::resize(winSize[0],winSize[1]);
227 renderer->RemoveAllViewProps();
235 renderer->RemoveActor(actor);
243 renderer->RemoveActor(actor);
251 return renderer->GetActors();
258 return renderer->GetVolumes();
265 if(!imageActors.empty())
266 return imageActors.last().imageActor;
284 scalarBar->SetScalarBarActor(bar);
300 renderer->GetBackground(red, green, blue);
333 return QVTKWidget::GetRenderWindow()->GetInteractor();
342 QVTKWidget::GetRenderWindow()->OffScreenRenderingOn();
350 QVTKWidget::GetRenderWindow()->OffScreenRenderingOff();
359 QVTKWidget::GetRenderWindow()->Render();
366 void enableUpdates(QStatusBar *bar);
373 void addModelActor(vtkSmartPointer<vtkActor> mdlActor);
378 void removeModelActor(vtkSmartPointer<vtkActor> mdlActor);
383 void addActor(vtkSmartPointer<vtkActor> imgActor, vtkMatrix4x4 *transformMatrix = NULL);
388 void addImageActor(vtkSmartPointer<vtkImageActor> imgActor, vtkMatrix4x4 *transformMatrix = NULL);
393 void removeImageActor(vtkSmartPointer<vtkImageActor> imgActor);
404 { importFrom(windowToImportFrom); }
409 virtual void updateTextActor(vtkObject * obj,
unsigned long,
void * client_data,
void *, vtkCommand * command);
414 virtual void updateImageActor(vtkObject * obj,
unsigned long,
void * client_data,
void *, vtkCommand * command);
415 virtual void updateImageActor(vtkSmartPointer<vtkImageActor> actor);
417 void userEvent(QMouseEvent *event = NULL);
418 void userEvent(QKeyEvent *event);
419 void userEvent(QWheelEvent *event);
431 {
return transformMatrix; }
449 void linkProgressEventOf(vtkObject * obj);
454 virtual void updateCoords(vtkObject *obj);
459 virtual void contour();
464 void contourAsPolyData();
469 void contourAsNodePolyData();
474 void contourInitFromPolyData(QString filename =
"");
479 void enableAxes(
float xScale = 1.0,
float yScale = 1.0,
float zScale = 1.0);
494 void disableOrient();
499 void orientDisplay();
504 virtual void background(
bool white =
false);
526 virtual void viewToXYPlane();
527 inline void viewToAxial()
535 virtual void viewToZXPlane();
536 inline void viewToCoronal()
544 virtual void viewToZYPlane();
545 inline void viewToSagittal()
557 {
return orientationView; }
566 { orientationView = orientMode; }
573 {
return currentView; }
579 void setView(
int viewMode);
584 void enableActionBasedOnView();
592 { useDefaultView =
false; }
599 inline void enableDefaultView()
600 { useDefaultView =
true; }
607 { defaultView = viewMode; }
612 void saveView(QString filename =
"");
618 void loadView(QString filename =
"");
626 virtual void enableScale(QString title =
"",
const bool quiet =
false,
double minRange = 0.0,
double maxRange = 0.0,
int noOfLabels = 3) {}
631 virtual void disableScale();
640 renderWindow->SetCurrentCursor(VTK_CURSOR_CROSSHAIR);
641 crosshairAct->setChecked(
true);
650 renderWindow->SetCurrentCursor(0);
651 crosshairAct->setChecked(
false);
665 virtual void colourMapToRainbow(
double minRange = 0.0,
double maxRange = 0.0);
670 virtual void colourMapToVTK(
double minRange = 0.0,
double maxRange = 0.0);
675 virtual void colourMapToGray(
double minRange = 0.0,
double maxRange = 0.0);
680 virtual void colourMapToSeismic(
double minRange = 0.0,
double maxRange = 0.0);
685 virtual void colourMapToLogGray(
double minRange = 0.0,
double maxRange = 0.0);
690 virtual void colourMapToJet(
double minRange = 0.0,
double maxRange = 0.0);
695 virtual void colourMapToNIH(
double minRange = 0.0,
double maxRange = 0.0);
700 virtual void colourMapToNIH_Fire(
double minRange = 0.0,
double maxRange = 0.0);
705 virtual void colourMapToAAL(
double minRange = 0.0,
double maxRange = 0.0);
710 virtual void colourMapToFS(
double minRange = 0.0,
double maxRange = 0.0);
715 virtual void colourMapToHOT(
double minRange = 0.0,
double maxRange = 0.0);
720 virtual void colourMapToCOOL(
double minRange = 0.0,
double maxRange = 0.0);
725 virtual void colourMapToCOOLWARM(
double minRange = 0.0,
double maxRange = 0.0);
730 virtual void colourMapToKnee(
double minRange = 0.0,
double maxRange = 0.0);
735 virtual void colourMapToBone(
double minRange = 0.0,
double maxRange = 0.0);
740 virtual void colourMapToSpectral(
double minRange = 0.0,
double maxRange = 0.0);
745 virtual void colourMapToGNUPlot(
double minRange = 0.0,
double maxRange = 0.0);
750 virtual void colourMapToCubeHelix(
double minRange = 0.0,
double maxRange = 0.0);
755 virtual void colourMapToHSV(
double minRange = 0.0,
double maxRange = 0.0);
760 virtual void updateLookupTable();
769 void generateRender();
778 windowActionGroup = actionGrp;
784 void createCustomConnections(QList<QAction *> actionsInMenu);
789 void createCustomConnections(QMenu *fromMenu);
796 virtual void customOperation();
802 virtual void createMenu(QMenu *menu);
811 bool openModelUsingQt(
const QString filename, vtkSmartPointer<vtkPolyData> &data);
818 void imageAvailable(vtkImageData*, QString );
823 void modelAvailable(vtkPolyData*, QString );
828 void tableToPlot(vtkSmartPointer<vtkTable>, QString);
833 void modified(vtkSmartPointer<vtkImageActor> );
841 bool customScalarBar;
925 vtkSmartPointer<vtkScalarBarActor>
scale;
927 vtkSmartPointer<vtkAxesActor>
axes;
954 void createActions();
959 void createConnections();
964 void contextMenuEvent(QContextMenuEvent *event);
969 QMenu* colourMapsMenu();
974 void dragMoveEvent(QDragMoveEvent *event);
979 void dragLeaveEvent(QDragLeaveEvent *event);
984 void dragEnterEvent(QDragEnterEvent *event);
989 void mouseDoubleClickEvent(QMouseEvent *event);
994 void dropEvent(QDropEvent *event);
1000 virtual void SetupWidgets(vtkRenderWindowInteractor *interactor);
1006 void setupHumanGlyph(vtkSmartPointer<vtkMatrix4x4> mat = NULL);
1012 #endif // MILXQTRENDERWINDOW_H QAction * scaleAct
Action for the scale bar of the display.
vtkLookupTable * GetLookupTable()
Get the lookup table of the colours in display window.
int defaultView
Default view for data (default is axial)
QPoint dragStartPosition
Dragging helper variable.
bool logScale
Using custom scalar bar?
int getDefaultOrientation()
Get the orientation mode to one of the supported standards.
vtkSmartPointer< vtkAxesActor > axes
Axes for the model.
void RemoveActor(vtkSmartPointer< vtkProp > actor)
Remove the VTK actor from this window.
LabelledAction * actionGNUPlot
GNUPlot colours.
QAction * saveViewFileAct
Save camera view to file.
LabelledAction * actionHSV
Cube Helix colours.
QMenu * viewMenu
Context Menu.
vtkSmartPointer< vtkBoxWidget2 > boxWidget
Used for measuring angles.
void disableDefaultView()
Disables the default view whenever data is process or displayed. Enabled by default.
QAction * lightingAct
Action for two-sided lighting of the display.
int currentView
Current view for data.
virtual void enableScale(QString title="", const bool quiet=false, double minRange=0.0, double maxRange=0.0, int noOfLabels=3)
Enable scale bar display with the title provided.
QActionGroup * windowActionGroup
used for the custom menu
void SetActor(vtkSmartPointer< vtkProp > actor)
Add a VTK actor to this window. Alias for AddActor.
vtkActorCollection * GetActors()
Get all the actors in the render window.
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 RemoveActor2D(vtkSmartPointer< vtkProp > actor)
Remove the VTK 2D actor from this window.
vtkSmartPointer< vtkLookupTable > lookupTable
Lookup table for the shapes/images, base class is used to allow references to different look up table...
void SetActor2D(vtkSmartPointer< vtkProp > actor)
Add a VTK actor to this window. Alias for AddActor2D.
QAction * viewZY
Change view to zy-plane (Coronal)
void AddVolume(vtkSmartPointer< vtkVolume > actor)
Add a VTK volume to this window.
QAction * actionNIH
NIH colours.
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.
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.
void SetLookupTable(vtkSmartPointer< vtkLookupTable > lut)
Set the lookup table of the colours in display window.
vtkSmartPointer< vtkOrientationMarkerWidget > humanGlyph
Glyph for showing equivalent view on human.
QAction * crosshairAct
Action for crosshair.
void setCustomActionGroup(QActionGroup *actionGrp)
Set the action group for the menu with custom connections.
LabelledAction * actionCubeHelix
Cube Helix colours.
This class represents the MILX Qt Window Display object using QVTK.
QAction * humanAct
Show human view orientation glyph?
QAction * actionInvRainbow
Inv Default colours.
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.
QAction * contourPolyDataAct
Save contour surface points as polydata.
QAction * lineAct
Action for distance measuring display.
virtual void disableCrosshair()
Restores the mouse pointer to default.
QAction * actionRainbow
Default colours.
QAction * actionDefault
Default colours.
QAction * contourAct
Action for contouring surface points using Dijkstras algorithm.
bool orientationAxes
Display orientation (posterior etc.) axes?
void OffScreenRenderingOn()
Enable off-screen rendering, which is faster for large datasets in some instances.
QList< ImageActorItem > imageActors
Images actors being displayed in model view.
void Render()
Force Render or Update of the display.
LabelledAction * actionBone
Spectral colours.
void OffScreenRenderingOff()
Disable off-screen rendering, which is faster for large datasets in some instances.
void setDefaultOrientation(int orientMode)
Change orientation mode to one of the supported standards. Default: Radiological. ...
#define MILXQT_EXPORT
Define Windows DLL importing.
QAction * actionJet
Jet colours.
virtual vtkRenderWindowInteractor * GetVTKInteractor()
Get the interactor associated with the view rendering.
int orientationView
view orientation standard
QAction * contourNodePolyDataAct
Save contour surface nodes as polydata.
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?
QMenu * contourMenu
Contour Menu.
void SetRenderer(vtkRenderer *rnder)
Assigns a VTK Renderer object.
void GetBackground(double &red, double &green, double &blue)
Get the background of the display window.
QAction * resetAct
Action for refreshing the display.
QMenu * colourMapMenu
Colour map menu.
void SetScalarBar(vtkScalarBarActor *bar)
Get the scalar bar of the display window.
LabelledAction * actionHOT
HOT colours.
virtual void scaleDisplay(const bool forceDisplay=false)
Toggles the scale bar display.
QAction * saveViewAct
Save camera view.
bool isLoaded()
Is the data successfully loaded? Use this to check if all is ok with data display.
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)
vtkScalarBarActor * GetScalarBar()
Get the scalar bar of the display window.
QActionGroup * mapGroup
Grouping for check boxes.
vtkSmartPointer< vtkPlaneWidget > planeWidget
Used for drawing planes.
vtkSmartPointer< vtkCamera > camera
camera for the view
void AddActor2D(vtkSmartPointer< vtkProp > actor)
Add a VTK actor to this window.
LabelledAction * actionGray
Gray colours.
void RemoveAllActors()
Remove all VTK actors from this window.
QAction * actionCOOL
COOL colours.
bool rendered
Scene as been setup for rendering? (by generateRender())
vtkSmartPointer< vtkSphereWidget2 > sphereWidget
Used for measuring angles.
void SetBackground(double red, double green, double blue)
Set the background of the display window.
void SetSize(int height, int width)
Set the size of the display window.
QAction * viewZX
Change view to zx-plane (Sagittal)
LabelledAction * actionCOOLWARM
COOL colours.
vtkSmartPointer< vtkScalarBarActor > scale
Scale for the display.
LabelledAction * actionSeismic
Gray2 colours.
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.
vtkSmartPointer< vtkSphereRepresentation > sphereRep
Sphere for widgets.
void setDefaultView(int viewMode)
Change default view to view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
QAction * biDirectionAct
Action for cross distance measuring display.
QList< vtkSmartPointer< vtkTextActor > > textActors
text actors for text widgets
virtual vtkImageActor * GetImageActor()
Get the image actors, Implement in derived class that uses images.
vtkSmartPointer< vtkRenderWindow > renderWindow
Render Window used if no other set, only for deletion, access through QVTKWidget members.
QAction * actionFS
FS colours.
bool useDefaultView
Using log scalar map?
QAction * actionAAL
AAL colours.
vtkSmartPointer< vtkEventQtSlotConnect > Connector
VTK Events to slots convertor.
vtkSmartPointer< vtkScalarBarWidget > scalarBar
Scalar Bar Widget for the display.
int getView()
Return current view mode identified by number. 0-axial, 1-coronal, 2-sagittal.
QMenu * windowPropertiesMenu
Context Menu.
vtkRenderer * GetRenderer()
Returns the VTK Renderer object.
vtkVolumeCollection * GetVolumes()
Get all the actors in the render window.
QAction * planeAct
Action for drawing planes.
QAction * angleAct
Action for angle measuring display.
void importViewFrom(milxQtRenderWindow *windowToImportFrom)
Same as importFrom()
QStatusBar * updateBar
Pointer to bar, not allocated or deleted. To be passed to only.
QAction * loadViewAct
Load camera view.
vtkSmartPointer< vtkPointPicker > dataPicker
For determining coordinates and points from the window.
QAction * sphereAct
Action for sphere annotate display.
QAction * loadViewFileAct
Load camera view to file.