Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "mitkFeedbackContourTool.h"
00019 #include "mitkToolManager.h"
00020
00021 #include "mitkProperties.h"
00022 #include "mitkStringProperty.h"
00023 #include "mitkColorProperty.h"
00024
00025 #include "mitkDataStorage.h"
00026 #include "mitkBaseRenderer.h"
00027
00028 #include "mitkRenderingManager.h"
00029
00030 mitk::FeedbackContourTool::FeedbackContourTool(const char* type)
00031 :SegTool2D(type),
00032 m_FeedbackContourVisible(false),
00033 m_ContourUtils(ContourUtils::New())
00034 {
00035 m_FeedbackContour = Contour::New();
00036 m_FeedbackContourNode = DataNode::New();
00037 m_FeedbackContourNode->SetData( m_FeedbackContour );
00038 m_FeedbackContourNode->SetProperty("name", StringProperty::New("One of FeedbackContourTool's feedback nodes"));
00039 m_FeedbackContourNode->SetProperty("visible", BoolProperty::New(true));
00040 m_FeedbackContourNode->SetProperty("helper object", BoolProperty::New(true));
00041 m_FeedbackContourNode->SetProperty("layer", IntProperty::New(1000));
00042 m_FeedbackContourNode->SetProperty("project", BoolProperty::New(true));
00043 m_FeedbackContourNode->SetProperty("Width", FloatProperty::New(1));
00044
00045
00046 const RenderingManager::RenderWindowVector& renderWindows = RenderingManager::GetInstance()->GetAllRegisteredRenderWindows();
00047 for (RenderingManager::RenderWindowVector::const_iterator iter = renderWindows.begin();
00048 iter != renderWindows.end();
00049 ++iter)
00050 {
00051 if ( mitk::BaseRenderer::GetInstance((*iter))->GetMapperID() == BaseRenderer::Standard3D )
00052
00053 {
00054 m_FeedbackContourNode->SetProperty("visible", BoolProperty::New(false), mitk::BaseRenderer::GetInstance((*iter)));
00055 }
00056 }
00057
00058 SetFeedbackContourColorDefault();
00059 }
00060
00061 mitk::FeedbackContourTool::~FeedbackContourTool()
00062 {
00063 }
00064
00065 void mitk::FeedbackContourTool::SetFeedbackContourColor( float r, float g, float b )
00066 {
00067 m_FeedbackContourNode->SetProperty("color", ColorProperty::New(r, g, b));
00068 }
00069
00070 void mitk::FeedbackContourTool::SetFeedbackContourColorDefault()
00071 {
00072 m_FeedbackContourNode->SetProperty("color", ColorProperty::New(0.0/255.0, 255.0/255.0, 0.0/255.0));
00073 }
00074
00075 mitk::Contour* mitk::FeedbackContourTool::GetFeedbackContour()
00076 {
00077 return m_FeedbackContour;
00078 }
00079
00080 void mitk::FeedbackContourTool::SetFeedbackContour(Contour& contour)
00081 {
00082 m_FeedbackContour = &contour;
00083 m_FeedbackContourNode->SetData( m_FeedbackContour );
00084 }
00085
00086 void mitk::FeedbackContourTool::SetFeedbackContourVisible(bool visible)
00087 {
00088 if ( m_FeedbackContourVisible == visible ) return;
00089
00090 if ( DataStorage* storage = m_ToolManager->GetDataStorage() )
00091 {
00092 if (visible)
00093 {
00094 storage->Add( m_FeedbackContourNode );
00095 }
00096 else
00097 {
00098 storage->Remove( m_FeedbackContourNode );
00099 }
00100 }
00101
00102 m_FeedbackContourVisible = visible;
00103 }
00104
00105 mitk::Contour::Pointer mitk::FeedbackContourTool::ProjectContourTo2DSlice(Image* slice, Contour* contourIn3D, bool correctionForIpSegmentation, bool constrainToInside)
00106 {
00107 return m_ContourUtils->ProjectContourTo2DSlice(slice, contourIn3D, correctionForIpSegmentation, constrainToInside);
00108 }
00109
00110 mitk::Contour::Pointer mitk::FeedbackContourTool::BackProjectContourFrom2DSlice(Image* slice, Contour* contourIn2D, bool correctionForIpSegmentation)
00111 {
00112 return m_ContourUtils->BackProjectContourFrom2DSlice(slice, contourIn2D, correctionForIpSegmentation);
00113 }
00114
00115 void mitk::FeedbackContourTool::FillContourInSlice( Contour* projectedContour, Image* sliceImage, int paintingPixelValue )
00116 {
00117 m_ContourUtils->FillContourInSlice(projectedContour, sliceImage, paintingPixelValue);
00118 }
00119