16 #include <vtkCornerAnnotation.h> 17 #include <vtkTextProperty.h> 20 const QString& widgetName,
23 , m_WidgetName(widgetName)
25 , m_RenderWindow(nullptr)
26 , m_PointSetNode(nullptr)
29 this->InitializeGUI();
35 if (
nullptr != sliceNavigationController)
39 if (
nullptr != m_DataStorage)
41 m_DataStorage->
Remove(m_PointSetNode);
47 if (dataStorage == m_DataStorage)
52 m_DataStorage = dataStorage;
53 if (
nullptr != m_RenderWindow)
77 if (
nullptr == vtkRenderer)
82 m_GradientBackgroundColors.first = upper;
83 m_GradientBackgroundColors.second = lower;
84 vtkRenderer->SetBackground(lower[0], lower[1], lower[2]);
85 vtkRenderer->SetBackground2(upper[0], upper[1], upper[2]);
102 m_DecorationColor = color;
103 m_CornerAnnotation->GetTextProperty()->SetColor(m_DecorationColor[0], m_DecorationColor[1], m_DecorationColor[2]);
105 QColor hexColor(m_DecorationColor[0] * 255, m_DecorationColor[1] * 255, m_DecorationColor[2] * 255);
106 setStyleSheet(
"QmitkRenderWindowWidget { border: 2px solid " + hexColor.name(QColor::HexRgb) +
"; }");
113 setFrameStyle(QFrame::Box | QFrame::Plain);
117 setFrameStyle(NoFrame);
123 return frameStyle() > 0;
128 m_CornerAnnotation->SetVisibility(show);
133 return m_CornerAnnotation->GetVisibility() > 0;
138 m_CornerAnnotation->SetText(0, cornerAnnotation.c_str());
143 return std::string(m_CornerAnnotation->GetText(0));
153 if (
nullptr == m_DataStorage)
162 m_DataStorage->
Add(m_PointSetNode);
164 catch(std::invalid_argument& )
172 m_DataStorage->
Remove(m_PointSetNode);
176 void QmitkRenderWindowWidget::InitializeGUI()
178 m_Layout =
new QHBoxLayout(
this);
179 m_Layout->setMargin(0);
181 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
182 setContentsMargins(0, 0, 0, 0);
184 if (
nullptr == m_DataStorage)
201 m_Layout->addWidget(m_RenderWindow);
205 m_PointSetNode->SetProperty(
"name",
mitk::StringProperty::New(
"Crosshair of render window " + m_WidgetName.toStdString()));
209 m_PointSetNode->SetBoolProperty(
"fixedLayer",
true, m_RenderWindow->
GetRenderer());
210 m_PointSetNode->SetVisibility(
true, m_RenderWindow->
GetRenderer());
211 m_PointSetNode->SetVisibility(
false);
214 m_PointSetNode->SetData(m_PointSet);
217 InitializeDecorations();
220 void QmitkRenderWindowWidget::InitializeDecorations()
223 if (
nullptr == vtkRenderer)
229 float black[3] = { 0.0f, 0.0f, 0.0f };
233 float white[3] = { 1.0f, 1.0f, 1.0f };
234 m_DecorationColor = white;
236 setFrameStyle(QFrame::Box | QFrame::Plain);
237 QColor hexColor(m_DecorationColor[0] * 255, m_DecorationColor[1] * 255, m_DecorationColor[2] * 255);
238 setStyleSheet(
"border: 2px solid " + hexColor.name(QColor::HexRgb));
240 m_CornerAnnotation = vtkSmartPointer<vtkCornerAnnotation>::New();
241 m_CornerAnnotation->SetText(0,
"Sagittal");
242 m_CornerAnnotation->SetMaximumFontSize(12);
243 m_CornerAnnotation->GetTextProperty()->SetColor(m_DecorationColor[0], m_DecorationColor[1], m_DecorationColor[2]);
244 if (0 == vtkRenderer->HasViewProp(m_CornerAnnotation))
246 vtkRenderer->AddViewProp(m_CornerAnnotation);
250 void QmitkRenderWindowWidget::SetCrosshair(
mitk::Point3D selectedPoint)
252 m_PointSet->SetPoint(1, selectedPoint, 0);
virtual bool InitializeViews(const BaseGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace=false)
Data management class that handles 'was created by' relations.
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
vtkRenderer * GetVtkRenderer() const
TimeGeometry::ConstPointer ComputeBoundingGeometry3D(const SetOfObjects *input, const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
Compute the axis-parallel bounding geometry of the input objects.
virtual void Add(DataNode *node, const DataStorage::SetOfObjects *parents=nullptr)=0
Adds a DataNode containing a data object to its internal storage.
Controls the selection of the slice the associated BaseRenderer will display.
Message1< mitk::Point3D > SetCrosshairEvent
virtual SetOfObjects::ConstPointer GetAll() const =0
returns a set of all data objects that are stored in the data storage
mitk::DataStorage::Pointer m_DataStorage
bool GetActivateMenuWidgetFlag()
static RenderingManager * GetInstance()
void SetDataStorage(mitk::DataStorage *storage)
Setter / Getter for internal DataStorage.
MITK implementation of the QVTKWidget.
virtual mitk::VtkPropRenderer * GetRenderer()
void ForceImmediateUpdate(vtkRenderWindow *renderWindow)
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
virtual void Remove(const DataNode *node)=0
Removes node from the DataStorage.
void RequestUpdate(vtkRenderWindow *renderWindow)
virtual mitk::SliceNavigationController * GetSliceNavigationController()
void SetLayoutIndex(QmitkRenderWindowMenu::LayoutIndex layoutIndex)