37 #include "QVTKWidget.h"
38 #include "vtkEventQtSlotConnect.h"
39 #include "vtkLookupTable.h"
40 #include "vtkRenderWindow.h"
41 #include "vtkRendererCollection.h"
42 #include "vtkImageData.h"
43 #include "vtkTextProperty.h"
49 #include "vtkIntArray.h"
50 #include "vtkConstrainedPointHandleRepresentation.h"
51 #include "vtkSeedWidget.h"
52 #include "vtkImageActorPointPlacer.h"
53 #include "vtkProperty.h"
54 #include "vtkWidgetEvent.h"
55 #include "vtkWidgetEventTranslator.h"
59 #include "vtkDistanceWidget.h"
62 #include "vtkAngleWidget.h"
65 #include "vtkContourWidget.h"
66 #include "vtkOrientedGlyphContourRepresentation.h"
67 #include "vtkPolyData.h"
77 m_IntersectionLineWidth(1.),
79 m_ShowAnnotations(true),
80 m_ShowSplinePlane(true)
137 if ( !(( current_rgb[0] == r )
138 && ( current_rgb[1] == g )
139 && ( current_rgb[2] == b )) )
143 if ( ( r != 0.5 ) && ( g != 0.5 ) && ( b != 0.5 ) )
145 textcolor[0] = 1. - r;
146 textcolor[1] = 1. - g;
147 textcolor[2] = 1. - b;
156 double rgb[3] = { r, g, b };
159 int n =
m_Pool->GetNumberOfItems();
161 for (
int i = 0; i < n; i++ )
163 vtkTextProperty *tproperty =
165 tproperty->SetFontFamilyToArial();
166 tproperty->SetFontSize(14);
167 tproperty->SetColor(textcolor);
192 static_cast< double >( g ),
193 static_cast< double >( b ) );
217 return m_Pool->GetNumberOfItems();
221 std::vector< vtkActor * >
224 int n =
m_Pool->GetNumberOfItems();
226 std::vector< vtkActor * > oActorVector(n, (vtkActor *)NULL);
233 for (
int i = 0; i < n; i++ )
236 vtkActor * temp = viewer->
AddDataSet(iDataset, iProperty);
237 oActorVector[i] = temp;
250 if ( ( iId >= 0 ) && ( iId < m_Pool->GetNumberOfItems() ) )
253 viewer->GetRenderer()->RemoveActor(iActor);
263 if ( ( iId >= 0 ) && ( iId < m_Pool->GetNumberOfItems() ) )
266 viewer->GetRenderer()->AddActor(iActor);
319 if ( this->
m_Image->GetNumberOfScalarComponents() == 1 )
321 m_Pool->SyncSetLookupTable(iLut);
331 if ( this->
m_Image->GetNumberOfScalarComponents() == 1 )
333 m_Pool->SyncSetShowScalarBar(iShow);
358 int N = this->
m_Pool->GetNumberOfItems();
360 if ( ( iId < 0 ) || ( iId >= N ) )
384 m_Pool->SyncSetInterpolate(val);
408 int N = this->
m_Pool->GetNumberOfItems();
410 for (
int i = 0; i < N; ++i )
412 this->
m_Handle.push_back(vtkSmartPointer< vtkConstrainedPointHandleRepresentation >::New());
413 this->
m_Handle.back()->GetProperty()->SetColor(1, 0, 0);
415 this->
m_SeedRep.push_back(vtkSmartPointer< vtkSeedRepresentation >::New());
418 this->
m_SeedWidget.push_back(vtkSmartPointer< vtkSeedWidget >::New());
425 this->
m_SeedWidget[i]->GetEventTranslator()->RemoveTranslation(
426 vtkCommand::RightButtonPressEvent);
428 this->
m_SeedWidget[i]->GetEventTranslator()->SetTranslation(
429 vtkCommand::KeyPressEvent, vtkEvent::NoModifier, 100, 0,
"d", vtkWidgetEvent::Delete);
444 std::vector< vtkSmartPointer< vtkSeedWidget > >::iterator
448 ( *it )->SetEnabled(iEnable);
459 for (
unsigned int i = 0; i < 3; i++ )
461 double worldPosition[3];
462 int N = this->
m_SeedRep[i]->GetNumberOfSeeds();
464 for (
int j = 0; j < N; j++ )
468 this->
m_SeedRep[i]->GetSeedWorldPosition(j, worldPosition);
470 iPoints[i]->InsertNextPoint(worldPosition);
480 for (
unsigned int i = 0; i < this->
m_SeedWidget.size(); i++ )
482 for (
int k = this->
m_SeedRep[i]->GetNumberOfSeeds() - 1; k >= 0; --k )
496 int N = this->
m_Pool->GetNumberOfItems();
499 for (
int i = 0; i < N; ++i )
520 int N = this->
m_Pool->GetNumberOfItems();
521 for (
int i = 0; i < N; i++ )
531 int N = this->
m_Pool->GetNumberOfItems();
534 for (
int i = 0; i < N; ++i )
536 this->
m_AngleWidget[i] = vtkSmartPointer< vtkAngleWidget >::New();
555 int N = this->
m_Pool->GetNumberOfItems();
556 for (
int i = 0; i < N; i++ )
573 int N = this->
m_Pool->GetNumberOfItems();
579 for (
int i = 0; i < N; ++i )
583 vtkSmartPointer< vtkOrientedGlyphContourRepresentation >::New();
606 std::vector< vtkSmartPointer< vtkContourWidget > >::iterator
610 ( *it )->SetEnabled(iActivate);
619 if ( ( iDir >= 0 ) && ( iDir < m_Pool->GetNumberOfItems() ) )
635 for (
int i = 0; i < N; i++ )
652 linecolor.
getRgbF(&rl, &gl, &bl);
655 nodecolor.
getRgbF(&rn, &gn, &bn);
658 activenodecolor.
getRgbF(&ra, &ga, &ba);
660 std::vector< vtkSmartPointer< vtkOrientedGlyphContourRepresentation > >::iterator
664 ( *it )->GetLinesProperty()->SetLineWidth(linewidth);
665 ( *it )->GetLinesProperty()->SetColor(
666 static_cast< double >( rl ),
667 static_cast< double >( gl ),
668 static_cast< double >( bl ) );
670 ( *it )->GetProperty()->SetColor(
671 static_cast< double >( rn ),
672 static_cast< double >( gn ),
673 static_cast< double >( bn ) );
675 ( *it )->GetActiveProperty()->SetColor(
676 static_cast< double >( ra ),
677 static_cast< double >( ga ),
678 static_cast< double >( ba ) );
694 vtkPolyData *contour_nodes = vtkPolyData::New();
698 return contour_nodes;
705 std::vector< vtkSmartPointer< vtkOrientedGlyphContourRepresentation > >::iterator
711 vtkSmartPointer< vtkImageActorPointPlacer > point_placer =
712 vtkSmartPointer< vtkImageActorPointPlacer >::New();
715 ( *it )->SetPointPlacer(point_placer);
virtual void SyncResetWindowLevel(void)
Description: Synchronize reset window level between views.
vtkImageData * GetImage()
Get the displaid image.
void ResetWindowLevel()
Reset collection Window level.
double * GetBackgroundColor()
void UpdateContourRepresentationProperties(float linewidth, QColor linecolor, QColor nodecolor, QColor activenodecolor)
void SetIntersectionLineWidth(const float &iWidth)
void SetInterpolate(const int &val)
Interpolate the data for visualization.
void UpdateRenderWindows()
Update only the visualization.
void InitializeSeedWidget()
Initializae the seed widget.
void ReinitializeContourWidget()
virtual void AddActor(const int &iId, vtkActor *iActor)
void ShowScalarBar(const bool &)
Show/hide the scalar bar in the collection.
void PanMode()
Use the pan interactor style.
vtkPolyData * GetContourRepresentationAsPolydata(int iDir)
void InitializeContourWidget()
Initializae the angle widget.
void getRgbF(qreal *r, qreal *g, qreal *b, qreal *a) const
void EnableContourPickingMode()
Use the contour picking mode.
void GetSeeds(std::vector< vtkPoints * > &iPoints)
virtual void SyncRender()
Description: Synchronize render between views.
virtual vtkActor * AddDataSet(vtkPolyData *polydata, vtkProperty *property=NULL, const bool &intersection=true, const bool &iDataVisibility=false)
Add a dataset to the view (has to be subclass of vtkPointSet). The dataset will be cut through the im...
void EnableContourPickingMode()
Change Interaction mode of the collection to ContourPickingMode()
vtkPolyData * GetContourRepresentationNodePolydata(int iDir)
void SetLookupTable(vtkLookupTable *iLut)
Set the lookup table in the collection.
virtual int * GetImageCoordinatesFromWorldCoordinates(double position[3])
Convert a world coordinate point into an image indices coordinate point.
vtkViewImage2D * GetImageViewer(const int &iId)
void EnableDistanceWidget(bool iEnable)
QString fromUtf8(const char *str, int size)
void SetSplinePlaneActorsVisibility(bool iVisibility)
Set the visibility of the plane actor.
void ZoomMode()
Use the zoom interactor style.
void EnableDefaultInteractionMode()
Change Interaction mode of the collection to DefaultMode()
std::vector< vtkSmartPointer< vtkContourWidget > > m_ContourWidget
virtual void ChangeCursorShape(QCursor iCursorShape)=0
void ClearAllSeeds()
Clear all the seeds positions after using it.
void InitializeContourWidgetNodes(int iDir, vtkPolyData *iNodes)
void InitializeDistanceWidget()
Initializae the distance widget.
void SyncSetBackground(double *rgb)
void EnableSeedWidget(bool iEnable)
std::vector< vtkSmartPointer< vtkSeedWidget > > m_SeedWidget
QGoImageView(QWidget *parent=0)
Default Constructor.
virtual double * GetBackground(void)
std::vector< vtkSmartPointer< vtkDistanceWidget > > m_DistanceWidget
std::vector< vtkSmartPointer< vtkAngleWidget > > m_AngleWidget
void EnableZoomInteractionMode()
Change Interaction mode of the collection to ZoomMode()
static vtkViewImage2DCollection * New()
Convenient method to access the constructor.
virtual std::vector< vtkActor * > AddContour(vtkPolyData *iDataset, vtkProperty *iProperty=NULL)
Add contour with given property into the visualization.
int * GetImageCoordinatesFromWorldCoordinates(double pos[3])
Get Image Coordinates from World Coordinates.
void ShowSplinePlane()
Invert visibility of the Spline Plane.
virtual vtkRenderWindowInteractor * GetInteractor()
QColor m_ActiveNodesColor
void InitializeAngleWidget()
Initializae the angle widget.
void EnableContourWidget(bool iActivate)
virtual ~QGoImageView()
Destructor.
std::vector< vtkSmartPointer< vtkSeedRepresentation > > m_SeedRep
void EnablePanInteractionMode()
Change Interaction mode of the collection to ZoomMode()
vtkViewImage2D * GetItem(int i)
void EnableAngleWidget(bool iActive)
int GetNumberOfImageViewers()
std::vector< vtkSmartPointer< vtkConstrainedPointHandleRepresentation > > m_Handle
vtkImageActor * GetImageActor(const int &iId)
Get the image actor.
void SyncUpdateWindowLevel(void)
float m_IntersectionLineWidth
void SetBackgroundColor(const double &r, const double &g, const double &b)
Set background color for all views.
virtual void RemoveActor(const int &iId, vtkActor *iActor)
void DefaultMode()
Use the default interactor style.
vtkViewImage2DCollection * m_Pool
Basic class to handle 2D/3D items such as images and polydatas visualization in 2D.
void ShowAnnotations()
Show annotations in the collection.
std::vector< vtkSmartPointer< vtkOrientedGlyphContourRepresentation > > m_ContourRepresentation