diff --git a/Core/Code/Rendering/mitkImageVtkMapper2D.cpp b/Core/Code/Rendering/mitkImageVtkMapper2D.cpp index 9db61c7bd3..9a4f923fff 100644 --- a/Core/Code/Rendering/mitkImageVtkMapper2D.cpp +++ b/Core/Code/Rendering/mitkImageVtkMapper2D.cpp @@ -1,1073 +1,1072 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include #include #include #include #include #include #include #include #include #include #include //#include #include #include "mitkImageStatisticsHolder.h" #include "mitkPlaneClipping.h" //MITK Rendering #include "mitkImageVtkMapper2D.h" #include "vtkMitkThickSlicesFilter.h" #include "vtkMitkLevelWindowFilter.h" #include "vtkNeverTranslucentTexture.h" //VTK #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //ITK #include #include mitk::ImageVtkMapper2D::ImageVtkMapper2D() { } mitk::ImageVtkMapper2D::~ImageVtkMapper2D() { //The 3D RW Mapper (PlaneGeometryDataVtkMapper3D) is listening to this event, //in order to delete the images from the 3D RW. this->InvokeEvent( itk::DeleteEvent() ); } //set the two points defining the textured plane according to the dimension and spacing void mitk::ImageVtkMapper2D::GeneratePlane(mitk::BaseRenderer* renderer, double planeBounds[6]) { LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); float depth = this->CalculateLayerDepth(renderer); //Set the origin to (xMin; yMin; depth) of the plane. This is necessary for obtaining the correct //plane size in crosshair rotation and swivel mode. localStorage->m_Plane->SetOrigin(planeBounds[0], planeBounds[2], depth); //These two points define the axes of the plane in combination with the origin. //Point 1 is the x-axis and point 2 the y-axis. //Each plane is transformed according to the view (axial, coronal and saggital) afterwards. localStorage->m_Plane->SetPoint1(planeBounds[1] , planeBounds[2], depth); //P1: (xMax, yMin, depth) localStorage->m_Plane->SetPoint2(planeBounds[0], planeBounds[3], depth); //P2: (xMin, yMax, depth) } float mitk::ImageVtkMapper2D::CalculateLayerDepth(mitk::BaseRenderer* renderer) { //get the clipping range to check how deep into z direction we can render images double maxRange = renderer->GetVtkRenderer()->GetActiveCamera()->GetClippingRange()[1]; //Due to a VTK bug, we cannot use the whole clipping range. /100 is empirically determined float depth = -maxRange*0.01; // divide by 100 int layer = 0; GetDataNode()->GetIntProperty( "layer", layer, renderer); //add the layer property for each image to render images with a higher layer on top of the others depth += layer*10; //*10: keep some room for each image (e.g. for QBalls in between) if(depth > 0.0f) { depth = 0.0f; MITK_WARN << "Layer value exceeds clipping range. Set to minimum instead."; } return depth; } const mitk::Image* mitk::ImageVtkMapper2D::GetInput( void ) { return static_cast< const mitk::Image * >( GetDataNode()->GetData() ); } vtkProp* mitk::ImageVtkMapper2D::GetVtkProp(mitk::BaseRenderer* renderer) { //return the actor corresponding to the renderer return m_LSH.GetLocalStorage(renderer)->m_Actors; } void mitk::ImageVtkMapper2D::GenerateDataForRenderer( mitk::BaseRenderer *renderer ) { LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); mitk::Image *input = const_cast< mitk::Image * >( this->GetInput() ); mitk::DataNode* datanode = this->GetDataNode(); if ( input == NULL || input->IsInitialized() == false ) { return; } //check if there is a valid worldGeometry const PlaneGeometry *worldGeometry = renderer->GetCurrentWorldPlaneGeometry(); if( ( worldGeometry == NULL ) || ( !worldGeometry->IsValid() ) || ( !worldGeometry->HasReferenceGeometry() )) { return; } input->Update(); // early out if there is no intersection of the current rendering geometry // and the geometry of the image that is to be rendered. if ( !RenderingGeometryIntersectsImage( worldGeometry, input->GetSlicedGeometry() ) ) { // set image to NULL, to clear the texture in 3D, because // the latest image is used there if the plane is out of the geometry // see bug-13275 localStorage->m_ReslicedImage = NULL; localStorage->m_Mapper->SetInputData( localStorage->m_EmptyPolyData ); return; } //set main input for ExtractSliceFilter localStorage->m_Reslicer->SetInput(input); localStorage->m_Reslicer->SetWorldGeometry(worldGeometry); localStorage->m_Reslicer->SetTimeStep( this->GetTimestep() ); //set the transformation of the image to adapt reslice axis localStorage->m_Reslicer->SetResliceTransformByGeometry( input->GetTimeGeometry()->GetGeometryForTimeStep( this->GetTimestep() ) ); //is the geometry of the slice based on the input image or the worldgeometry? bool inPlaneResampleExtentByGeometry = false; datanode->GetBoolProperty("in plane resample extent by geometry", inPlaneResampleExtentByGeometry, renderer); localStorage->m_Reslicer->SetInPlaneResampleExtentByGeometry(inPlaneResampleExtentByGeometry); // Initialize the interpolation mode for resampling; switch to nearest // neighbor if the input image is too small. if ( (input->GetDimension() >= 3) && (input->GetDimension(2) > 1) ) { VtkResliceInterpolationProperty *resliceInterpolationProperty; datanode->GetProperty( resliceInterpolationProperty, "reslice interpolation" ); int interpolationMode = VTK_RESLICE_NEAREST; if ( resliceInterpolationProperty != NULL ) { interpolationMode = resliceInterpolationProperty->GetInterpolation(); } switch ( interpolationMode ) { case VTK_RESLICE_NEAREST: localStorage->m_Reslicer->SetInterpolationMode(ExtractSliceFilter::RESLICE_NEAREST); break; case VTK_RESLICE_LINEAR: localStorage->m_Reslicer->SetInterpolationMode(ExtractSliceFilter::RESLICE_LINEAR); break; case VTK_RESLICE_CUBIC: localStorage->m_Reslicer->SetInterpolationMode(ExtractSliceFilter::RESLICE_CUBIC); break; } } else { localStorage->m_Reslicer->SetInterpolationMode(ExtractSliceFilter::RESLICE_NEAREST); } //set the vtk output property to true, makes sure that no unneeded mitk image convertion //is done. localStorage->m_Reslicer->SetVtkOutputRequest(true); //Thickslicing int thickSlicesMode = 0; int thickSlicesNum = 1; // Thick slices parameters if( input->GetPixelType().GetNumberOfComponents() == 1 ) // for now only single component are allowed { DataNode *dn=renderer->GetCurrentWorldPlaneGeometryNode(); if(dn) { ResliceMethodProperty *resliceMethodEnumProperty=0; if( dn->GetProperty( resliceMethodEnumProperty, "reslice.thickslices" ) && resliceMethodEnumProperty ) thickSlicesMode = resliceMethodEnumProperty->GetValueAsId(); IntProperty *intProperty=0; if( dn->GetProperty( intProperty, "reslice.thickslices.num" ) && intProperty ) { thickSlicesNum = intProperty->GetValue(); if(thickSlicesNum < 1) thickSlicesNum=1; - if(thickSlicesNum > 10) thickSlicesNum=10; } } else { MITK_WARN << "no associated widget plane data tree node found"; } } const PlaneGeometry *planeGeometry = dynamic_cast< const PlaneGeometry * >( worldGeometry ); if(thickSlicesMode > 0) { double dataZSpacing = 1.0; Vector3D normInIndex, normal; if ( planeGeometry != NULL ){ normal = planeGeometry->GetNormal(); }else{ const mitk::AbstractTransformGeometry* abstractGeometry = dynamic_cast< const AbstractTransformGeometry * >(worldGeometry); if(abstractGeometry != NULL) normal = abstractGeometry->GetPlane()->GetNormal(); else return; //no fitting geometry set } normal.Normalize(); input->GetTimeGeometry()->GetGeometryForTimeStep( this->GetTimestep() )->WorldToIndex( normal, normInIndex ); dataZSpacing = 1.0 / normInIndex.GetNorm(); localStorage->m_Reslicer->SetOutputDimensionality( 3 ); localStorage->m_Reslicer->SetOutputSpacingZDirection(dataZSpacing); localStorage->m_Reslicer->SetOutputExtentZDirection( -thickSlicesNum, 0+thickSlicesNum ); // Do the reslicing. Modified() is called to make sure that the reslicer is // executed even though the input geometry information did not change; this // is necessary when the input /em data, but not the /em geometry changes. localStorage->m_TSFilter->SetThickSliceMode( thickSlicesMode-1 ); localStorage->m_TSFilter->SetInputData( localStorage->m_Reslicer->GetVtkOutput() ); //vtkFilter=>mitkFilter=>vtkFilter update mechanism will fail without calling manually localStorage->m_Reslicer->Modified(); localStorage->m_Reslicer->Update(); localStorage->m_TSFilter->Modified(); localStorage->m_TSFilter->Update(); localStorage->m_ReslicedImage = localStorage->m_TSFilter->GetOutput(); } else { //this is needed when thick mode was enable bevore. These variable have to be reset to default values localStorage->m_Reslicer->SetOutputDimensionality( 2 ); localStorage->m_Reslicer->SetOutputSpacingZDirection(1.0); localStorage->m_Reslicer->SetOutputExtentZDirection( 0, 0 ); localStorage->m_Reslicer->Modified(); //start the pipeline with updating the largest possible, needed if the geometry of the input has changed localStorage->m_Reslicer->UpdateLargestPossibleRegion(); localStorage->m_ReslicedImage = localStorage->m_Reslicer->GetVtkOutput(); } // Bounds information for reslicing (only reuqired if reference geometry // is present) //this used for generating a vtkPLaneSource with the right size double sliceBounds[6]; for ( int i = 0; i < 6; ++i ) { sliceBounds[i] = 0.0; } localStorage->m_Reslicer->GetClippedPlaneBounds(sliceBounds); //get the spacing of the slice localStorage->m_mmPerPixel = localStorage->m_Reslicer->GetOutputSpacing(); // calculate minimum bounding rect of IMAGE in texture { double textureClippingBounds[6]; for ( int i = 0; i < 6; ++i ) { textureClippingBounds[i] = 0.0; } // Calculate the actual bounds of the transformed plane clipped by the // dataset bounding box; this is required for drawing the texture at the // correct position during 3D mapping. mitk::PlaneClipping::CalculateClippedPlaneBounds( input->GetGeometry(), planeGeometry, textureClippingBounds ); textureClippingBounds[0] = static_cast< int >( textureClippingBounds[0] / localStorage->m_mmPerPixel[0] + 0.5 ); textureClippingBounds[1] = static_cast< int >( textureClippingBounds[1] / localStorage->m_mmPerPixel[0] + 0.5 ); textureClippingBounds[2] = static_cast< int >( textureClippingBounds[2] / localStorage->m_mmPerPixel[1] + 0.5 ); textureClippingBounds[3] = static_cast< int >( textureClippingBounds[3] / localStorage->m_mmPerPixel[1] + 0.5 ); //clipping bounds for cutting the image localStorage->m_LevelWindowFilter->SetClippingBounds(textureClippingBounds); } //get the number of scalar components to distinguish between different image types int numberOfComponents = localStorage->m_ReslicedImage->GetNumberOfScalarComponents(); //get the binary property bool binary = false; bool binaryOutline = false; datanode->GetBoolProperty( "binary", binary, renderer ); if(binary) //binary image { datanode->GetBoolProperty( "outline binary", binaryOutline, renderer ); if(binaryOutline) //contour rendering { if ( input->GetPixelType().GetBpe() <= 8 ) { //generate contours/outlines localStorage->m_OutlinePolyData = CreateOutlinePolyData(renderer); float binaryOutlineWidth(1.0); if ( datanode->GetFloatProperty( "outline width", binaryOutlineWidth, renderer ) ) { if ( localStorage->m_Actors->GetNumberOfPaths() > 1 ) { float binaryOutlineShadowWidth(1.5); datanode->GetFloatProperty( "outline shadow width", binaryOutlineShadowWidth, renderer ); dynamic_cast(localStorage->m_Actors->GetParts()->GetItemAsObject(0)) ->GetProperty()->SetLineWidth( binaryOutlineWidth * binaryOutlineShadowWidth ); } localStorage->m_Actor->GetProperty()->SetLineWidth( binaryOutlineWidth ); } } else { binaryOutline = false; this->ApplyLookuptable(renderer); MITK_WARN << "Type of all binary images should be (un)signed char. Outline does not work on other pixel types!"; } } else //standard binary image { if(numberOfComponents != 1) { MITK_ERROR << "Rendering Error: Binary Images with more then 1 component are not supported!"; } } } this->ApplyOpacity( renderer ); this->ApplyRenderingMode(renderer); // do not use a VTK lookup table (we do that ourselves in m_LevelWindowFilter) localStorage->m_Texture->MapColorScalarsThroughLookupTableOff(); int displayedComponent = 0; if (datanode->GetIntProperty("Image.Displayed Component", displayedComponent, renderer) && numberOfComponents > 1) { localStorage->m_VectorComponentExtractor->SetComponents(displayedComponent); localStorage->m_VectorComponentExtractor->SetInputData(localStorage->m_ReslicedImage); localStorage->m_LevelWindowFilter->SetInputConnection(localStorage->m_VectorComponentExtractor->GetOutputPort(0)); } else { //connect the input with the levelwindow filter localStorage->m_LevelWindowFilter->SetInputData(localStorage->m_ReslicedImage); } // check for texture interpolation property bool textureInterpolation = false; GetDataNode()->GetBoolProperty( "texture interpolation", textureInterpolation, renderer ); //set the interpolation modus according to the property localStorage->m_Texture->SetInterpolate(textureInterpolation); // connect the texture with the output of the levelwindow filter localStorage->m_Texture->SetInputConnection(localStorage->m_LevelWindowFilter->GetOutputPort()); this->TransformActor( renderer ); vtkActor* contourShadowActor = dynamic_cast (localStorage->m_Actors->GetParts()->GetItemAsObject(0)); if(binary && binaryOutline) //connect the mapper with the polyData which contains the lines { //We need the contour for the binary outline property as actor localStorage->m_Mapper->SetInputData(localStorage->m_OutlinePolyData); localStorage->m_Actor->SetTexture(NULL); //no texture for contours bool binaryOutlineShadow( false ); datanode->GetBoolProperty( "outline binary shadow", binaryOutlineShadow, renderer ); if ( binaryOutlineShadow ) contourShadowActor->SetVisibility( true ); else contourShadowActor->SetVisibility( false ); } else { //Connect the mapper with the input texture. This is the standard case. //setup the textured plane this->GeneratePlane( renderer, sliceBounds ); //set the plane as input for the mapper localStorage->m_Mapper->SetInputConnection(localStorage->m_Plane->GetOutputPort()); //set the texture for the actor localStorage->m_Actor->SetTexture(localStorage->m_Texture); contourShadowActor->SetVisibility( false ); } // We have been modified => save this for next Update() localStorage->m_LastUpdateTime.Modified(); } void mitk::ImageVtkMapper2D::ApplyLevelWindow(mitk::BaseRenderer *renderer) { LocalStorage *localStorage = this->GetLocalStorage( renderer ); LevelWindow levelWindow; this->GetDataNode()->GetLevelWindow( levelWindow, renderer, "levelwindow" ); localStorage->m_LevelWindowFilter->GetLookupTable()->SetRange( levelWindow.GetLowerWindowBound(), levelWindow.GetUpperWindowBound() ); mitk::LevelWindow opacLevelWindow; if( this->GetDataNode()->GetLevelWindow( opacLevelWindow, renderer, "opaclevelwindow" ) ) { //pass the opaque level window to the filter localStorage->m_LevelWindowFilter->SetMinOpacity(opacLevelWindow.GetLowerWindowBound()); localStorage->m_LevelWindowFilter->SetMaxOpacity(opacLevelWindow.GetUpperWindowBound()); } else { //no opaque level window localStorage->m_LevelWindowFilter->SetMinOpacity(0.0); localStorage->m_LevelWindowFilter->SetMaxOpacity(255.0); } } void mitk::ImageVtkMapper2D::ApplyColor( mitk::BaseRenderer* renderer ) { LocalStorage *localStorage = this->GetLocalStorage( renderer ); float rgb[3]= { 1.0f, 1.0f, 1.0f }; // check for color prop and use it for rendering if it exists // binary image hovering & binary image selection bool hover = false; bool selected = false; GetDataNode()->GetBoolProperty("binaryimage.ishovering", hover, renderer); GetDataNode()->GetBoolProperty("selected", selected, renderer); if(hover && !selected) { mitk::ColorProperty::Pointer colorprop = dynamic_cast(GetDataNode()->GetProperty ("binaryimage.hoveringcolor", renderer)); if(colorprop.IsNotNull()) { memcpy(rgb, colorprop->GetColor().GetDataPointer(), 3*sizeof(float)); } else { GetDataNode()->GetColor( rgb, renderer, "color" ); } } if(selected) { mitk::ColorProperty::Pointer colorprop = dynamic_cast(GetDataNode()->GetProperty ("binaryimage.selectedcolor", renderer)); if(colorprop.IsNotNull()) { memcpy(rgb, colorprop->GetColor().GetDataPointer(), 3*sizeof(float)); } else { GetDataNode()->GetColor(rgb, renderer, "color"); } } if(!hover && !selected) { GetDataNode()->GetColor( rgb, renderer, "color" ); } double rgbConv[3] = {(double)rgb[0], (double)rgb[1], (double)rgb[2]}; //conversion to double for VTK dynamic_cast (localStorage->m_Actors->GetParts()->GetItemAsObject(0))->GetProperty()->SetColor(rgbConv); localStorage->m_Actor->GetProperty()->SetColor(rgbConv); if ( localStorage->m_Actors->GetParts()->GetNumberOfItems() > 1 ) { float rgb[3]= { 1.0f, 1.0f, 1.0f }; mitk::ColorProperty::Pointer colorprop = dynamic_cast(GetDataNode()->GetProperty ("outline binary shadow color", renderer)); if(colorprop.IsNotNull()) { memcpy(rgb, colorprop->GetColor().GetDataPointer(), 3*sizeof(float)); } double rgbConv[3] = {(double)rgb[0], (double)rgb[1], (double)rgb[2]}; //conversion to double for VTK dynamic_cast( localStorage->m_Actors->GetParts()->GetItemAsObject(0) )->GetProperty()->SetColor(rgbConv); } } void mitk::ImageVtkMapper2D::ApplyOpacity( mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = this->GetLocalStorage( renderer ); float opacity = 1.0f; // check for opacity prop and use it for rendering if it exists GetDataNode()->GetOpacity( opacity, renderer, "opacity" ); //set the opacity according to the properties localStorage->m_Actor->GetProperty()->SetOpacity(opacity); if ( localStorage->m_Actors->GetParts()->GetNumberOfItems() > 1 ) { dynamic_cast( localStorage->m_Actors->GetParts()->GetItemAsObject(0) )->GetProperty()->SetOpacity(opacity); } } void mitk::ImageVtkMapper2D::ApplyRenderingMode( mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = m_LSH.GetLocalStorage(renderer); bool binary = false; this->GetDataNode()->GetBoolProperty( "binary", binary, renderer ); if(binary) // is it a binary image? { //for binary images, we always use our default LuT and map every value to (0,1) //the opacity of 0 will always be 0.0. We never a apply a LuT/TfF nor a level window. localStorage->m_LevelWindowFilter->SetLookupTable(localStorage->m_BinaryLookupTable); } else { //all other image types can make use of the rendering mode int renderingMode = mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR; mitk::RenderingModeProperty::Pointer mode = dynamic_cast(this->GetDataNode()->GetProperty( "Image Rendering.Mode", renderer )); if(mode.IsNotNull()) { renderingMode = mode->GetRenderingMode(); } switch(renderingMode) { case mitk::RenderingModeProperty::LOOKUPTABLE_LEVELWINDOW_COLOR: MITK_DEBUG << "'Image Rendering.Mode' = LevelWindow_LookupTable_Color"; this->ApplyLookuptable( renderer ); this->ApplyLevelWindow( renderer ); break; case mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_LEVELWINDOW_COLOR: MITK_DEBUG << "'Image Rendering.Mode' = LevelWindow_ColorTransferFunction_Color"; this->ApplyColorTransferFunction( renderer ); this->ApplyLevelWindow( renderer ); break; case mitk::RenderingModeProperty::LOOKUPTABLE_COLOR: MITK_DEBUG << "'Image Rendering.Mode' = LookupTable_Color"; this->ApplyLookuptable( renderer ); break; case mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_COLOR: MITK_DEBUG << "'Image Rendering.Mode' = ColorTransferFunction_Color"; this->ApplyColorTransferFunction( renderer ); break; default: MITK_ERROR << "No valid 'Image Rendering.Mode' set. Using LOOKUPTABLE_LEVELWINDOW_COLOR instead."; this->ApplyLookuptable( renderer ); this->ApplyLevelWindow( renderer ); break; } } //we apply color for all images (including binaries). this->ApplyColor( renderer ); } void mitk::ImageVtkMapper2D::ApplyLookuptable( mitk::BaseRenderer* renderer ) { LocalStorage* localStorage = m_LSH.GetLocalStorage(renderer); vtkLookupTable* usedLookupTable = localStorage->m_ColorLookupTable; // If lookup table or transferfunction use is requested... mitk::LookupTableProperty::Pointer lookupTableProp = dynamic_cast(this->GetDataNode()->GetProperty("LookupTable")); if( lookupTableProp.IsNotNull() ) // is a lookuptable set? { usedLookupTable = lookupTableProp->GetLookupTable()->GetVtkLookupTable(); } else { //"Image Rendering.Mode was set to use a lookup table but there is no property 'LookupTable'. //A default (rainbow) lookup table will be used. //Here have to do nothing. Warning for the user has been removed, due to unwanted console output //in every interation of the rendering. } localStorage->m_LevelWindowFilter->SetLookupTable(usedLookupTable); } void mitk::ImageVtkMapper2D::ApplyColorTransferFunction(mitk::BaseRenderer *renderer) { mitk::TransferFunctionProperty::Pointer transferFunctionProp = dynamic_cast(this->GetDataNode()->GetProperty("Image Rendering.Transfer Function",renderer )); if( transferFunctionProp.IsNull() ) { MITK_ERROR << "'Image Rendering.Mode'' was set to use a color transfer function but there is no property 'Image Rendering.Transfer Function'. Nothing will be done."; return; } LocalStorage* localStorage = m_LSH.GetLocalStorage(renderer); //pass the transfer function to our level window filter localStorage->m_LevelWindowFilter->SetLookupTable(transferFunctionProp->GetValue()->GetColorTransferFunction()); } void mitk::ImageVtkMapper2D::Update(mitk::BaseRenderer* renderer) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if ( !visible ) { return; } mitk::Image* data = const_cast( this->GetInput() ); if ( data == NULL ) { return; } // Calculate time step of the input data for the specified renderer (integer value) this->CalculateTimeStep( renderer ); // Check if time step is valid const TimeGeometry *dataTimeGeometry = data->GetTimeGeometry(); if ( ( dataTimeGeometry == NULL ) || ( dataTimeGeometry->CountTimeSteps() == 0 ) || ( !dataTimeGeometry->IsValidTimeStep( this->GetTimestep() ) ) ) { return; } const DataNode *node = this->GetDataNode(); data->UpdateOutputInformation(); LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); //check if something important has changed and we need to rerender if ( (localStorage->m_LastUpdateTime < node->GetMTime()) //was the node modified? || (localStorage->m_LastUpdateTime < data->GetPipelineMTime()) //Was the data modified? || (localStorage->m_LastUpdateTime < renderer->GetCurrentWorldPlaneGeometryUpdateTime()) //was the geometry modified? || (localStorage->m_LastUpdateTime < renderer->GetCurrentWorldPlaneGeometry()->GetMTime()) || (localStorage->m_LastUpdateTime < node->GetPropertyList()->GetMTime()) //was a property modified? || (localStorage->m_LastUpdateTime < node->GetPropertyList(renderer)->GetMTime()) ) { this->GenerateDataForRenderer( renderer ); } // since we have checked that nothing important has changed, we can set // m_LastUpdateTime to the current time localStorage->m_LastUpdateTime.Modified(); } void mitk::ImageVtkMapper2D::SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer, bool overwrite) { mitk::Image::Pointer image = dynamic_cast(node->GetData()); // Properties common for both images and segmentations node->AddProperty( "depthOffset", mitk::FloatProperty::New( 0.0 ), renderer, overwrite ); node->AddProperty( "outline binary", mitk::BoolProperty::New( false ), renderer, overwrite ); node->AddProperty( "outline width", mitk::FloatProperty::New( 1.0 ), renderer, overwrite ); node->AddProperty( "outline binary shadow", mitk::BoolProperty::New( false ), renderer, overwrite ); node->AddProperty( "outline binary shadow color", ColorProperty::New(0.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "outline shadow width", mitk::FloatProperty::New( 1.5 ), renderer, overwrite ); if(image->IsRotated()) node->AddProperty( "reslice interpolation", mitk::VtkResliceInterpolationProperty::New(VTK_RESLICE_CUBIC) ); else node->AddProperty( "reslice interpolation", mitk::VtkResliceInterpolationProperty::New() ); node->AddProperty( "texture interpolation", mitk::BoolProperty::New( mitk::DataNodeFactory::m_TextureInterpolationActive ) ); // set to user configurable default value (see global options) node->AddProperty( "in plane resample extent by geometry", mitk::BoolProperty::New( false ) ); node->AddProperty( "bounding box", mitk::BoolProperty::New( false ) ); mitk::RenderingModeProperty::Pointer renderingModeProperty = mitk::RenderingModeProperty::New(); node->AddProperty( "Image Rendering.Mode", renderingModeProperty); // Set default grayscale look-up table mitk::LookupTable::Pointer mitkLut = mitk::LookupTable::New(); mitkLut->SetType(mitk::LookupTable::GRAYSCALE); mitk::LookupTableProperty::Pointer mitkLutProp = mitk::LookupTableProperty::New(); mitkLutProp->SetLookupTable(mitkLut); node->SetProperty("LookupTable", mitkLutProp); std::string photometricInterpretation; // DICOM tag telling us how pixel values should be displayed if ( node->GetStringProperty( "dicom.pixel.PhotometricInterpretation", photometricInterpretation ) ) { // modality provided by DICOM or other reader if ( photometricInterpretation.find("MONOCHROME1") != std::string::npos ) // meaning: display MINIMUM pixels as WHITE { // Set inverse grayscale look-up table mitkLut->SetType(mitk::LookupTable::INVERSE_GRAYSCALE); mitkLutProp->SetLookupTable(mitkLut); node->SetProperty("LookupTable", mitkLutProp); } // Otherwise do nothing - the default grayscale look-up table has already been set } bool isBinaryImage(false); if ( ! node->GetBoolProperty("binary", isBinaryImage) ) { // ok, property is not set, use heuristic to determine if this // is a binary image mitk::Image::Pointer centralSliceImage; ScalarType minValue = 0.0; ScalarType maxValue = 0.0; ScalarType min2ndValue = 0.0; ScalarType max2ndValue = 0.0; mitk::ImageSliceSelector::Pointer sliceSelector = mitk::ImageSliceSelector::New(); sliceSelector->SetInput(image); sliceSelector->SetSliceNr(image->GetDimension(2)/2); sliceSelector->SetTimeNr(image->GetDimension(3)/2); sliceSelector->SetChannelNr(image->GetDimension(4)/2); sliceSelector->Update(); centralSliceImage = sliceSelector->GetOutput(); if ( centralSliceImage.IsNotNull() && centralSliceImage->IsInitialized() ) { minValue = centralSliceImage->GetStatistics()->GetScalarValueMin(); maxValue = centralSliceImage->GetStatistics()->GetScalarValueMax(); min2ndValue = centralSliceImage->GetStatistics()->GetScalarValue2ndMin(); max2ndValue = centralSliceImage->GetStatistics()->GetScalarValue2ndMax(); } if ((maxValue == min2ndValue && minValue == max2ndValue) || minValue == maxValue) { // centralSlice is strange, lets look at all data minValue = image->GetStatistics()->GetScalarValueMin(); maxValue = image->GetStatistics()->GetScalarValueMaxNoRecompute(); min2ndValue = image->GetStatistics()->GetScalarValue2ndMinNoRecompute(); max2ndValue = image->GetStatistics()->GetScalarValue2ndMaxNoRecompute(); } isBinaryImage = ( maxValue == min2ndValue && minValue == max2ndValue ); } // some more properties specific for a binary... if (isBinaryImage) { node->AddProperty( "opacity", mitk::FloatProperty::New(0.3f), renderer, overwrite ); node->AddProperty( "color", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "binaryimage.selectedcolor", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "binaryimage.selectedannotationcolor", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "binaryimage.hoveringcolor", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "binaryimage.hoveringannotationcolor", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ); node->AddProperty( "binary", mitk::BoolProperty::New( true ), renderer, overwrite ); node->AddProperty("layer", mitk::IntProperty::New(10), renderer, overwrite); } else //...or image type object { node->AddProperty( "opacity", mitk::FloatProperty::New(1.0f), renderer, overwrite ); node->AddProperty( "color", ColorProperty::New(1.0,1.0,1.0), renderer, overwrite ); node->AddProperty( "binary", mitk::BoolProperty::New( false ), renderer, overwrite ); node->AddProperty("layer", mitk::IntProperty::New(0), renderer, overwrite); std::string className = image->GetNameOfClass(); if (className != "TensorImage" && className != "QBallImage") { PixelType pixelType = image->GetPixelType(); size_t numComponents = pixelType.GetNumberOfComponents(); if ((pixelType.GetPixelTypeAsString() == "vector" && numComponents > 1) || numComponents == 2 || numComponents > 4) node->AddProperty("Image.Displayed Component", mitk::IntProperty::New(0), renderer, overwrite); } } if(image.IsNotNull() && image->IsInitialized()) { if((overwrite) || (node->GetProperty("levelwindow", renderer)==NULL)) { /* initialize level/window from DICOM tags */ std::string sLevel; std::string sWindow; if ( image->GetPropertyList()->GetStringProperty( "dicom.voilut.WindowCenter", sLevel ) && image->GetPropertyList()->GetStringProperty( "dicom.voilut.WindowWidth", sWindow ) ) { float level = atof( sLevel.c_str() ); float window = atof( sWindow.c_str() ); mitk::LevelWindow contrast; std::string sSmallestPixelValueInSeries; std::string sLargestPixelValueInSeries; if ( image->GetPropertyList()->GetStringProperty( "dicom.series.SmallestPixelValueInSeries", sSmallestPixelValueInSeries ) && image->GetPropertyList()->GetStringProperty( "dicom.series.LargestPixelValueInSeries", sLargestPixelValueInSeries ) ) { float smallestPixelValueInSeries = atof( sSmallestPixelValueInSeries.c_str() ); float largestPixelValueInSeries = atof( sLargestPixelValueInSeries.c_str() ); contrast.SetRangeMinMax( smallestPixelValueInSeries-1, largestPixelValueInSeries+1 ); // why not a little buffer? // might remedy some l/w widget challenges } else { contrast.SetAuto( static_cast(node->GetData()), false, true ); // we need this as a fallback } contrast.SetLevelWindow( level, window, true ); node->SetProperty( "levelwindow", LevelWindowProperty::New( contrast ), renderer ); } } if(((overwrite) || (node->GetProperty("opaclevelwindow", renderer)==NULL)) && (image->GetPixelType().GetPixelType() == itk::ImageIOBase::RGBA) && (image->GetPixelType().GetComponentType() == itk::ImageIOBase::UCHAR) ) { mitk::LevelWindow opaclevwin; opaclevwin.SetRangeMinMax(0,255); opaclevwin.SetWindowBounds(0,255); mitk::LevelWindowProperty::Pointer prop = mitk::LevelWindowProperty::New(opaclevwin); node->SetProperty( "opaclevelwindow", prop, renderer ); } } Superclass::SetDefaultProperties(node, renderer, overwrite); } mitk::ImageVtkMapper2D::LocalStorage* mitk::ImageVtkMapper2D::GetLocalStorage(mitk::BaseRenderer* renderer) { return m_LSH.GetLocalStorage(renderer); } vtkSmartPointer mitk::ImageVtkMapper2D::CreateOutlinePolyData(mitk::BaseRenderer* renderer ){ LocalStorage* localStorage = this->GetLocalStorage(renderer); //get the min and max index values of each direction int* extent = localStorage->m_ReslicedImage->GetExtent(); int xMin = extent[0]; int xMax = extent[1]; int yMin = extent[2]; int yMax = extent[3]; int* dims = localStorage->m_ReslicedImage->GetDimensions(); //dimensions of the image int line = dims[0]; //how many pixels per line? int x = xMin; //pixel index x int y = yMin; //pixel index y char* currentPixel; //get the depth for each contour float depth = CalculateLayerDepth(renderer); vtkSmartPointer points = vtkSmartPointer::New(); //the points to draw vtkSmartPointer lines = vtkSmartPointer::New(); //the lines to connect the points // We take the pointer to the first pixel of the image currentPixel = static_cast(localStorage->m_ReslicedImage->GetScalarPointer() ); while (y <= yMax) { //if the current pixel value is set to something if ((currentPixel) && (*currentPixel != 0)) { //check in which direction a line is necessary //a line is added if the neighbor of the current pixel has the value 0 //and if the pixel is located at the edge of the image //if vvvvv not the first line vvvvv if (y > yMin && *(currentPixel-line) == 0) { //x direction - bottom edge of the pixel //add the 2 points vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); //add the line between both points lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv not the last line vvvvv if (y < yMax && *(currentPixel+line) == 0) { //x direction - top edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv not the first pixel vvvvv if ( (x > xMin || y > yMin) && *(currentPixel-1) == 0) { //y direction - left edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv not the last pixel vvvvv if ( (y < yMax || (x < xMax) ) && *(currentPixel+1) == 0) { //y direction - right edge of the pixel vtkIdType p1 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } /* now consider pixels at the edge of the image */ //if vvvvv left edge of image vvvvv if (x == xMin) { //draw left edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv right edge of image vvvvv if (x == xMax) { //draw right edge of the pixel vtkIdType p1 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv bottom edge of image vvvvv if (y == yMin) { //draw bottom edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], y*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } //if vvvvv top edge of image vvvvv if (y == yMax) { //draw top edge of the pixel vtkIdType p1 = points->InsertNextPoint(x*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); vtkIdType p2 = points->InsertNextPoint((x+1)*localStorage->m_mmPerPixel[0], (y+1)*localStorage->m_mmPerPixel[1], depth); lines->InsertNextCell(2); lines->InsertCellPoint(p1); lines->InsertCellPoint(p2); } }//end if currentpixel is set x++; if (x > xMax) { //reached end of line x = xMin; y++; } // Increase the pointer-position to the next pixel. // This is safe, as the while-loop and the x-reset logic above makes // sure we do not exceed the bounds of the image currentPixel++; }//end of while // Create a polydata to store everything in vtkSmartPointer polyData = vtkSmartPointer::New(); // Add the points to the dataset polyData->SetPoints(points); // Add the lines to the dataset polyData->SetLines(lines); return polyData; } void mitk::ImageVtkMapper2D::TransformActor(mitk::BaseRenderer* renderer) { LocalStorage *localStorage = m_LSH.GetLocalStorage(renderer); //get the transformation matrix of the reslicer in order to render the slice as axial, coronal or saggital vtkSmartPointer trans = vtkSmartPointer::New(); vtkSmartPointer matrix = localStorage->m_Reslicer->GetResliceAxes(); trans->SetMatrix(matrix); //transform the plane/contour (the actual actor) to the corresponding view (axial, coronal or saggital) localStorage->m_Actor->SetUserTransform(trans); //transform the origin to center based coordinates, because MITK is center based. localStorage->m_Actor->SetPosition( -0.5*localStorage->m_mmPerPixel[0], -0.5*localStorage->m_mmPerPixel[1], 0.0); if ( localStorage->m_Actors->GetNumberOfPaths() > 1 ) { vtkActor* secondaryActor = dynamic_cast( localStorage->m_Actors->GetParts()->GetItemAsObject(0) ); secondaryActor->SetUserTransform(trans); secondaryActor->SetPosition( -0.5*localStorage->m_mmPerPixel[0], -0.5*localStorage->m_mmPerPixel[1], 0.0); } } bool mitk::ImageVtkMapper2D::RenderingGeometryIntersectsImage( const PlaneGeometry* renderingGeometry, SlicedGeometry3D* imageGeometry ) { // if either one of the two geometries is NULL we return true // for safety reasons if ( renderingGeometry == NULL || imageGeometry == NULL ) return true; // get the distance for the first cornerpoint ScalarType initialDistance = renderingGeometry->SignedDistance( imageGeometry->GetCornerPoint( 0 ) ); for( int i=1; i<8; i++ ) { mitk::Point3D cornerPoint = imageGeometry->GetCornerPoint( i ); // get the distance to the other cornerpoints ScalarType distance = renderingGeometry->SignedDistance( cornerPoint ); // if it has not the same signing as the distance of the first point if ( initialDistance * distance < 0 ) { // we have an intersection and return true return true; } } // all distances have the same sign, no intersection and we return false return false; } mitk::ImageVtkMapper2D::LocalStorage::~LocalStorage() { } mitk::ImageVtkMapper2D::LocalStorage::LocalStorage() : m_VectorComponentExtractor(vtkSmartPointer::New()) { m_LevelWindowFilter = vtkSmartPointer::New(); //Do as much actions as possible in here to avoid double executions. m_Plane = vtkSmartPointer::New(); m_Texture = vtkSmartPointer::New().GetPointer(); m_DefaultLookupTable = vtkSmartPointer::New(); m_BinaryLookupTable = vtkSmartPointer::New(); m_ColorLookupTable = vtkSmartPointer::New(); m_Mapper = vtkSmartPointer::New(); m_Actor = vtkSmartPointer::New(); m_Actors = vtkSmartPointer::New(); m_Reslicer = mitk::ExtractSliceFilter::New(); m_TSFilter = vtkSmartPointer::New(); m_OutlinePolyData = vtkSmartPointer::New(); m_ReslicedImage = vtkSmartPointer::New(); m_EmptyPolyData = vtkSmartPointer::New(); //the following actions are always the same and thus can be performed //in the constructor for each image (i.e. the image-corresponding local storage) m_TSFilter->ReleaseDataFlagOn(); mitk::LookupTable::Pointer mitkLUT = mitk::LookupTable::New(); //built a default lookuptable mitkLUT->SetType(mitk::LookupTable::GRAYSCALE); m_DefaultLookupTable = mitkLUT->GetVtkLookupTable(); mitkLUT->SetType(mitk::LookupTable::LEGACY_BINARY); m_BinaryLookupTable = mitkLUT->GetVtkLookupTable(); mitkLUT->SetType(mitk::LookupTable::LEGACY_RAINBOW_COLOR); m_ColorLookupTable = mitkLUT->GetVtkLookupTable(); //do not repeat the texture (the image) m_Texture->RepeatOff(); //set the mapper for the actor m_Actor->SetMapper( m_Mapper ); vtkSmartPointer outlineShadowActor = vtkSmartPointer::New(); outlineShadowActor->SetMapper( m_Mapper ); m_Actors->AddPart( outlineShadowActor ); m_Actors->AddPart( m_Actor ); } diff --git a/Core/Code/Rendering/mitkPlaneGeometryDataMapper2D.cpp b/Core/Code/Rendering/mitkPlaneGeometryDataMapper2D.cpp index 93e077ba05..3bab93ecea 100644 --- a/Core/Code/Rendering/mitkPlaneGeometryDataMapper2D.cpp +++ b/Core/Code/Rendering/mitkPlaneGeometryDataMapper2D.cpp @@ -1,671 +1,670 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkGL.h" #include "mitkPlaneGeometryDataMapper2D.h" #include "mitkBaseRenderer.h" #include "mitkPlaneGeometry.h" #include "mitkColorProperty.h" #include "mitkProperties.h" #include "mitkSmartPointerProperty.h" #include "mitkPlaneOrientationProperty.h" #include "mitkPlaneGeometryDataToSurfaceFilter.h" #include "mitkSurfaceGLMapper2D.h" #include "mitkLine.h" #include "mitkNodePredicateDataType.h" #include "mitkSlicedGeometry3D.h" #include "mitkResliceMethodProperty.h" mitk::PlaneGeometryDataMapper2D::PlaneGeometryDataMapper2D() : m_SurfaceMapper( NULL ), m_DataStorage(NULL), m_ParentNode(NULL), m_OtherPlaneGeometries(), m_RenderOrientationArrows( false ), m_ArrowOrientationPositive( true ) { } mitk::PlaneGeometryDataMapper2D::~PlaneGeometryDataMapper2D() { } const mitk::PlaneGeometryData* mitk::PlaneGeometryDataMapper2D::GetInput(void) { return static_cast ( GetDataNode()->GetData() ); } void mitk::PlaneGeometryDataMapper2D::GenerateDataForRenderer(mitk::BaseRenderer* renderer) { BaseLocalStorage *ls = m_LSH.GetLocalStorage(renderer); if(!ls->IsGenerateDataRequired(renderer,this,GetDataNode())) return; ls->UpdateGenerateDataTime(); // collect all PlaneGeometryDatas accessible from the DataStorage m_OtherPlaneGeometries.clear(); if (m_DataStorage.IsNull()) return; mitk::NodePredicateDataType::Pointer p = mitk::NodePredicateDataType::New("PlaneGeometryData"); mitk::DataStorage::SetOfObjects::ConstPointer all = m_DataStorage->GetDerivations(m_ParentNode, p, false); for (mitk::DataStorage::SetOfObjects::ConstIterator it = all->Begin(); it != all->End(); ++it) { if(it->Value().IsNull()) continue; BaseData* data = it->Value()->GetData(); if (data == NULL) continue; PlaneGeometryData* geometry2dData = dynamic_cast(data); if(geometry2dData == NULL) continue; PlaneGeometry* planegeometry = dynamic_cast(geometry2dData->GetPlaneGeometry()); if (planegeometry != NULL) m_OtherPlaneGeometries.push_back(it->Value()); } } void mitk::PlaneGeometryDataMapper2D::Paint(BaseRenderer *renderer) { bool visible = true; GetDataNode()->GetVisibility(visible, renderer, "visible"); if(!visible) return; PlaneGeometryData::Pointer input = const_cast< PlaneGeometryData * >(this->GetInput()); // intersecting with ourself? if ( input.IsNull() || (this->GetInput()->GetPlaneGeometry() == renderer->GetCurrentWorldPlaneGeometry()) ) { return; // do nothing! } const PlaneGeometry *inputPlaneGeometry = dynamic_cast< const PlaneGeometry * >( input->GetPlaneGeometry() ); const PlaneGeometry *worldPlaneGeometry = dynamic_cast< const PlaneGeometry* >( renderer->GetCurrentWorldPlaneGeometry() ); if ( worldPlaneGeometry && inputPlaneGeometry && inputPlaneGeometry->GetReferenceGeometry() ) { DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry(); assert( displayGeometry ); const BaseGeometry *referenceGeometry = inputPlaneGeometry->GetReferenceGeometry(); // calculate intersection of the plane data with the border of the // world geometry rectangle Point2D lineFrom, lineTo; const Geometry3D::TransformType *transform = dynamic_cast< const Geometry3D::TransformType * >( referenceGeometry->GetIndexToWorldTransform() ); Geometry3D::TransformType::Pointer inverseTransform = Geometry3D::TransformType::New(); transform->GetInverse( inverseTransform ); Line3D crossLine, otherCrossLine; // Calculate the intersection line of the input plane with the world plane if ( worldPlaneGeometry->IntersectionLine( inputPlaneGeometry, crossLine ) ) { BoundingBox::PointType boundingBoxMin, boundingBoxMax; boundingBoxMin = referenceGeometry->GetBoundingBox()->GetMinimum(); boundingBoxMax = referenceGeometry->GetBoundingBox()->GetMaximum(); if(referenceGeometry->GetImageGeometry()) { for(unsigned int i = 0; i < 3; ++i) { boundingBoxMin[i]-=0.5; boundingBoxMax[i]-=0.5; } } crossLine.Transform( *inverseTransform ); Point3D point1, point2; // Then, clip this line with the (transformed) bounding box of the // reference geometry. if ( crossLine.BoxLineIntersection( boundingBoxMin[0], boundingBoxMin[1], boundingBoxMin[2], boundingBoxMax[0], boundingBoxMax[1], boundingBoxMax[2], crossLine.GetPoint(), crossLine.GetDirection(), point1, point2 ) == 2 ) { // Transform the resulting line start and end points into display // coordinates. worldPlaneGeometry->Map( transform->TransformPoint( point1 ), lineFrom ); worldPlaneGeometry->Map( transform->TransformPoint( point2 ), lineTo ); Line< ScalarType, 2 > mainLine, otherLine; Line< ScalarType, 2 > primaryHelperLine, secondaryHelperLine; mainLine.SetPoints( lineFrom, lineTo ); primaryHelperLine.SetPoints( lineFrom, lineTo ); secondaryHelperLine.SetPoints( lineFrom, lineTo ); displayGeometry->WorldToDisplay( lineFrom, lineFrom ); displayGeometry->WorldToDisplay( lineTo, lineTo ); ScalarType lengthInDisplayUnits = (lineTo - lineFrom).GetNorm(); Vector2D mainLineDirectionOrthogonal; mainLineDirectionOrthogonal[0] = -mainLine.GetDirection()[1]; mainLineDirectionOrthogonal[1] = mainLine.GetDirection()[0]; // lineParams stores the individual segments of the line, which are // separated by a gap each (to mark the intersection with another // displayed line) std::vector< ScalarType > mainLineParams; std::vector< ScalarType > primaryHelperLineParams; std::vector< ScalarType > secondaryHelperLineParams; mainLineParams.reserve( m_OtherPlaneGeometries.size() + 2 ); mainLineParams.push_back( 0.0 ); mainLineParams.push_back( 1.0 ); primaryHelperLineParams.reserve( m_OtherPlaneGeometries.size() + 2 ); primaryHelperLineParams.push_back( 0.0 ); primaryHelperLineParams.push_back( 1.0 ); secondaryHelperLineParams.reserve( m_OtherPlaneGeometries.size() + 2 ); secondaryHelperLineParams.push_back( 0.0 ); secondaryHelperLineParams.push_back( 1.0 ); // Now iterate through all other lines displayed in this window and // calculate the positions of intersection with the line to be // rendered; these positions will be stored in lineParams to form a // gap afterwards. NodesVectorType::iterator otherPlanesIt = m_OtherPlaneGeometries.begin(); NodesVectorType::iterator otherPlanesEnd = m_OtherPlaneGeometries.end(); - //int mainLineThickSlicesMode = 0; - int mainLineThickSlicesNum = 1; - DataNode* dataNodeOfInputPlaneGeometry = NULL; // Now we have to find the DataNode that contains the inputPlaneGeometry // in order to determine the state of the thick-slice rendering while ( otherPlanesIt != otherPlanesEnd ) { PlaneGeometry *otherPlane = static_cast< PlaneGeometry * >( static_cast< PlaneGeometryData * >( (*otherPlanesIt)->GetData() )->GetPlaneGeometry() ); // if we have found the correct node if ( (otherPlane == inputPlaneGeometry) && worldPlaneGeometry->IntersectionLine( otherPlane, otherCrossLine ) ) { dataNodeOfInputPlaneGeometry = (*otherPlanesIt); // if( dataNodeOfInputPlaneGeometry ) // { // mainLineThickSlicesMode = this->DetermineThickSliceMode(dataNodeOfInputPlaneGeometry, mainLineThickSlicesNum); // } break; } otherPlanesIt++; } // if we did not find a dataNode for the inputPlaneGeometry there is nothing we can do from here if ( dataNodeOfInputPlaneGeometry == NULL ) return; // Determine if we should draw the area covered by the thick slicing, default is false. // This will also show the area of slices that do not have thick slice mode enabled bool showAreaOfThickSlicing = false; dataNodeOfInputPlaneGeometry->GetBoolProperty( "reslice.thickslices.showarea", showAreaOfThickSlicing ); // get the normal of the inputPlaneGeometry Vector3D normal = inputPlaneGeometry->GetNormal(); // determine the pixelSpacing in that direction double thickSliceDistance = SlicedGeometry3D::CalculateSpacing( referenceGeometry->GetSpacing(), normal ); - // As the inputPlaneGeometry cuts through the center of the slice in the middle - // we have to add 0.5 pixel in order to compensate. - thickSliceDistance *= mainLineThickSlicesNum+0.5; + IntProperty *intProperty=0; + if( dataNodeOfInputPlaneGeometry->GetProperty( intProperty, "reslice.thickslices.num" ) && intProperty ) + thickSliceDistance *= intProperty->GetValue()+0.5; + else + showAreaOfThickSlicing = false; // not the nicest place to do it, but we have the width of the visible bloc in MM here // so we store it in this fancy property dataNodeOfInputPlaneGeometry->SetFloatProperty( "reslice.thickslices.sizeinmm", thickSliceDistance*2 ); if ( showAreaOfThickSlicing ) { // vectorToHelperLine defines how to reach the helperLine from the mainLine Vector2D vectorToHelperLine; vectorToHelperLine = mainLineDirectionOrthogonal; vectorToHelperLine.Normalize(); // got the right direction, so we multiply the width vectorToHelperLine *= thickSliceDistance; // and create the corresponding points primaryHelperLine.SetPoints( primaryHelperLine.GetPoint1() - vectorToHelperLine, primaryHelperLine.GetPoint2() - vectorToHelperLine ); secondaryHelperLine.SetPoints( secondaryHelperLine.GetPoint1() + vectorToHelperLine, secondaryHelperLine.GetPoint2() + vectorToHelperLine ); } //int otherLineThickSlicesMode = 0; - int otherLineThickSlicesNum = 1; + int otherLineThickSlicesNum = 0; // by default, there is no gap for the helper lines ScalarType gapSize = 0.0; otherPlanesIt = m_OtherPlaneGeometries.begin(); while ( otherPlanesIt != otherPlanesEnd ) { PlaneGeometry *otherPlane = static_cast< PlaneGeometry * >( static_cast< PlaneGeometryData * >( (*otherPlanesIt)->GetData() )->GetPlaneGeometry() ); // Just as with the original line, calculate the intersection with // the world geometry... if ( (otherPlane != inputPlaneGeometry) && worldPlaneGeometry->IntersectionLine( otherPlane, otherCrossLine ) ) { //otherLineThickSlicesMode = this->DetermineThickSliceMode((*otherPlanesIt), otherLineThickSlicesNum); Vector3D normal = otherPlane->GetNormal(); double otherLineThickSliceDistance = SlicedGeometry3D::CalculateSpacing( referenceGeometry->GetSpacing(), normal ); - otherLineThickSliceDistance *= (otherLineThickSlicesNum+0.5)*2; + otherLineThickSliceDistance *= (otherLineThickSlicesNum)*2; Point2D otherLineFrom, otherLineTo; // ... and clip the resulting line segment with the reference // geometry bounding box. otherCrossLine.Transform( *inverseTransform ); if ( otherCrossLine.BoxLineIntersection( boundingBoxMin[0], boundingBoxMin[1], boundingBoxMin[2], boundingBoxMax[0], boundingBoxMax[1], boundingBoxMax[2], otherCrossLine.GetPoint(), otherCrossLine.GetDirection(), point1, point2 ) == 2 ) { worldPlaneGeometry->Map( transform->TransformPoint( point1 ), otherLineFrom ); worldPlaneGeometry->Map( transform->TransformPoint( point2 ), otherLineTo ); otherLine.SetPoints( otherLineFrom, otherLineTo ); // then we have to determine the gap position of the main line // by finding the position at which the two lines cross this->DetermineParametricCrossPositions( mainLine, otherLine, mainLineParams ); // if the other line is also in thick slice mode, we have to determine the // gapsize considering the width of that other line and the spacing in its direction if ( showAreaOfThickSlicing ) { Vector2D otherLineDirection = otherLine.GetDirection(); otherLineDirection.Normalize(); mainLineDirectionOrthogonal.Normalize(); // determine the gapsize gapSize = fabs( otherLineThickSliceDistance / ( otherLineDirection*mainLineDirectionOrthogonal ) ); gapSize = gapSize / displayGeometry->GetScaleFactorMMPerDisplayUnit(); // determine the gap positions for the helper lines as well this->DetermineParametricCrossPositions( primaryHelperLine, otherLine, primaryHelperLineParams ); this->DetermineParametricCrossPositions( secondaryHelperLine, otherLine, secondaryHelperLineParams ); } } } ++otherPlanesIt; } // If we have to draw the helperlines, the mainline will be drawn as a dashed line // with a fixed gapsize of 10 pixels this->DrawLine(renderer, lengthInDisplayUnits, mainLine, mainLineParams, inputPlaneGeometry, showAreaOfThickSlicing, 10.0 ); // If drawn, the helperlines are drawn as a solid line. The gapsize depends on the // width of the crossed line. if ( showAreaOfThickSlicing ) { this->DrawLine(renderer, lengthInDisplayUnits, primaryHelperLine, primaryHelperLineParams, inputPlaneGeometry, false, gapSize ); this->DrawLine(renderer, lengthInDisplayUnits, secondaryHelperLine, secondaryHelperLineParams, inputPlaneGeometry, false, gapSize ); } } } } else { PlaneGeometryDataToSurfaceFilter::Pointer surfaceCreator; SmartPointerProperty::Pointer surfacecreatorprop; surfacecreatorprop = dynamic_cast< SmartPointerProperty * >( GetDataNode()->GetProperty( "surfacegeometry", renderer)); if( (surfacecreatorprop.IsNull()) || (surfacecreatorprop->GetSmartPointer().IsNull()) || ((surfaceCreator = dynamic_cast< PlaneGeometryDataToSurfaceFilter * >( surfacecreatorprop->GetSmartPointer().GetPointer())).IsNull()) ) { surfaceCreator = PlaneGeometryDataToSurfaceFilter::New(); surfacecreatorprop = SmartPointerProperty::New(surfaceCreator); surfaceCreator->PlaceByGeometryOn(); GetDataNode()->SetProperty( "surfacegeometry", surfacecreatorprop ); } surfaceCreator->SetInput( input ); // Clip the PlaneGeometry with the reference geometry bounds (if available) if ( input->GetPlaneGeometry()->HasReferenceGeometry() ) { surfaceCreator->SetBoundingBox( input->GetPlaneGeometry()->GetReferenceGeometry()->GetBoundingBox() ); } int res; bool usegeometryparametricbounds = true; if ( GetDataNode()->GetIntProperty("xresolution", res, renderer)) { surfaceCreator->SetXResolution(res); usegeometryparametricbounds=false; } if (GetDataNode()->GetIntProperty("yresolution", res, renderer)) { surfaceCreator->SetYResolution(res); usegeometryparametricbounds=false; } surfaceCreator->SetUseGeometryParametricBounds(usegeometryparametricbounds); // Calculate the surface of the PlaneGeometry surfaceCreator->Update(); if (m_SurfaceMapper.IsNull()) { m_SurfaceMapper=SurfaceGLMapper2D::New(); } m_SurfaceMapper->SetSurface(surfaceCreator->GetOutput()); m_SurfaceMapper->SetDataNode(GetDataNode()); m_SurfaceMapper->Paint(renderer); } } void mitk::PlaneGeometryDataMapper2D::DrawOrientationArrow( mitk::Point2D &outerPoint, mitk::Point2D &innerPoint, const mitk::PlaneGeometry *planeGeometry, const mitk::PlaneGeometry *rendererPlaneGeometry, const mitk::DisplayGeometry *displayGeometry, bool positiveOrientation ) { // Draw arrows to indicate plane orientation // Vector along line Vector2D v1 = innerPoint - outerPoint; v1.Normalize(); v1 *= 7.0; // Orthogonal vector Vector2D v2; v2[0] = v1[1]; v2[1] = -v1[0]; // Calculate triangle tip for one side and project it back into world // coordinates to determine whether it is above or below the plane Point2D worldPoint2D; Point3D worldPoint; displayGeometry->DisplayToWorld( outerPoint + v1 + v2, worldPoint2D ); rendererPlaneGeometry->Map( worldPoint2D, worldPoint ); // Initialize remaining triangle coordinates accordingly // (above/below state is XOR'ed with orientation flag) Point2D p1 = outerPoint + v1 * 2.0; Point2D p2 = outerPoint + v1 + ((positiveOrientation ^ planeGeometry->IsAbove( worldPoint )) ? v2 : -v2); // Draw the arrow (triangle) glBegin( GL_TRIANGLES ); glVertex2f( outerPoint[0], outerPoint[1] ); glVertex2f( p1[0], p1[1] ); glVertex2f( p2[0], p2[1] ); glEnd(); } void mitk::PlaneGeometryDataMapper2D::ApplyAllProperties( BaseRenderer *renderer ) { Superclass::ApplyColorAndOpacityProperties(renderer); PlaneOrientationProperty* decorationProperty; this->GetDataNode()->GetProperty( decorationProperty, "decoration", renderer ); if ( decorationProperty != NULL ) { if ( decorationProperty->GetPlaneDecoration() == PlaneOrientationProperty::PLANE_DECORATION_POSITIVE_ORIENTATION ) { m_RenderOrientationArrows = true; m_ArrowOrientationPositive = true; } else if ( decorationProperty->GetPlaneDecoration() == PlaneOrientationProperty::PLANE_DECORATION_NEGATIVE_ORIENTATION ) { m_RenderOrientationArrows = true; m_ArrowOrientationPositive = false; } else { m_RenderOrientationArrows = false; } } } void mitk::PlaneGeometryDataMapper2D::SetDatastorageAndGeometryBaseNode( mitk::DataStorage::Pointer ds, mitk::DataNode::Pointer parent ) { if (ds.IsNotNull()) { m_DataStorage = ds; } if (parent.IsNotNull()) { m_ParentNode = parent; } } void mitk::PlaneGeometryDataMapper2D::DrawLine( BaseRenderer* renderer, ScalarType lengthInDisplayUnits, Line &line, std::vector &gapPositions, const PlaneGeometry* inputPlaneGeometry, bool drawDashed, ScalarType gapSizeInPixel ) { DisplayGeometry *displayGeometry = renderer->GetDisplayGeometry(); const PlaneGeometry *worldPlaneGeometry = dynamic_cast< const PlaneGeometry* >( renderer->GetCurrentWorldPlaneGeometry() ); // Apply color and opacity read from the PropertyList. this->ApplyAllProperties( renderer ); ScalarType gapSizeInParamUnits = 1.0 / lengthInDisplayUnits * gapSizeInPixel; std::sort( gapPositions.begin(), gapPositions.end() ); Point2D p1, p2; ScalarType p1Param, p2Param; p1Param = gapPositions[0]; p1 = line.GetPoint( p1Param ); displayGeometry->WorldToDisplay( p1, p1 ); //Workaround to show the crosshair always on top of a 2D render window //The image is usually located at depth = 0 or negative depth values, and thus, //the crosshair with depth = 1 is always on top. float depthPosition = 1.0f; if ( drawDashed ) { glEnable(GL_LINE_STIPPLE); glLineStipple(1, 0xF0F0); } glEnable(GL_DEPTH_TEST); // Iterate over all line segments and display each, with a gap // in between. unsigned int i, preLastLineParam = gapPositions.size() - 1; for ( i = 1; i < preLastLineParam; ++i ) { p2Param = gapPositions[i] - gapSizeInParamUnits * 0.5; p2 = line.GetPoint( p2Param ); if ( p2Param > p1Param ) { // Convert intersection points (until now mm) to display // coordinates (units). displayGeometry->WorldToDisplay( p2, p2 ); // draw glBegin (GL_LINES); glVertex3f(p1[0],p1[1], depthPosition); glVertex3f(p2[0],p2[1], depthPosition); glEnd (); if ( (i == 1) && (m_RenderOrientationArrows) ) { // Draw orientation arrow for first line segment this->DrawOrientationArrow( p1, p2, inputPlaneGeometry, worldPlaneGeometry, displayGeometry, m_ArrowOrientationPositive ); } } p1Param = p2Param + gapSizeInParamUnits; p1 = line.GetPoint( p1Param ); displayGeometry->WorldToDisplay( p1, p1 ); } // Draw last line segment p2Param = gapPositions[i]; p2 = line.GetPoint( p2Param ); displayGeometry->WorldToDisplay( p2, p2 ); glBegin( GL_LINES ); glVertex3f( p1[0], p1[1], depthPosition); glVertex3f( p2[0], p2[1], depthPosition); glEnd(); if ( drawDashed ) { glDisable(GL_LINE_STIPPLE); } // Draw orientation arrows if ( m_RenderOrientationArrows ) { this->DrawOrientationArrow( p2, p1, inputPlaneGeometry, worldPlaneGeometry, displayGeometry, m_ArrowOrientationPositive ); if ( preLastLineParam < 2 ) { // If we only have one line segment, draw other arrow, too this->DrawOrientationArrow( p1, p2, inputPlaneGeometry, worldPlaneGeometry, displayGeometry, m_ArrowOrientationPositive ); } } } int mitk::PlaneGeometryDataMapper2D::DetermineThickSliceMode( DataNode * dn, int &thickSlicesNum ) { int thickSlicesMode = 0; // determine the state and the extend of the thick-slice mode mitk::ResliceMethodProperty *resliceMethodEnumProperty=0; if( dn->GetProperty( resliceMethodEnumProperty, "reslice.thickslices" ) && resliceMethodEnumProperty ) thickSlicesMode = resliceMethodEnumProperty->GetValueAsId(); IntProperty *intProperty=0; if( dn->GetProperty( intProperty, "reslice.thickslices.num" ) && intProperty ) { thickSlicesNum = intProperty->GetValue(); if(thickSlicesNum < 1) thickSlicesNum=0; if(thickSlicesNum > 10) thickSlicesNum=10; } if ( thickSlicesMode == 0 ) thickSlicesNum = 0; return thickSlicesMode; } void mitk::PlaneGeometryDataMapper2D::DetermineParametricCrossPositions( Line< mitk::ScalarType, 2 > &mainLine, Line< mitk::ScalarType, 2 > &otherLine, std::vector< mitk::ScalarType > &crossPositions ) { Vector2D direction, dOrth; // By means of the dot product, calculate the gap position as // parametric value in the range [0, 1] direction = otherLine.GetDirection(); dOrth[0] = -direction[1]; dOrth[1] = direction[0]; ScalarType gapPosition = ( otherLine.GetPoint1() - mainLine.GetPoint1() ) * dOrth; ScalarType norm = mainLine.GetDirection() * dOrth; if ( fabs( norm ) > eps ) { gapPosition /= norm; if ( (gapPosition > 0.0) && (gapPosition < 1.0) ) { crossPositions.push_back(gapPosition); } } } diff --git a/Modules/QtWidgets/QmitkRenderWindowMenu.cpp b/Modules/QtWidgets/QmitkRenderWindowMenu.cpp index ceb92c124b..2dfbedadc0 100644 --- a/Modules/QtWidgets/QmitkRenderWindowMenu.cpp +++ b/Modules/QtWidgets/QmitkRenderWindowMenu.cpp @@ -1,1026 +1,1027 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkRenderWindowMenu.h" #include "mitkResliceMethodProperty.h" #include "mitkProperties.h" #include #include #include #include #include #include #include #include #include #include #include #include "QmitkStdMultiWidget.h" //#include"iconClose.xpm" #include"iconFullScreen.xpm" #include"iconCrosshairMode.xpm" //#include"iconHoriSplit.xpm" #include"iconSettings.xpm" //#include"iconVertiSplit.xpm" #include"iconLeaveFullScreen.xpm" #include #ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU QmitkRenderWindowMenu::QmitkRenderWindowMenu(QWidget *parent, Qt::WindowFlags f, mitk::BaseRenderer *b, QmitkStdMultiWidget* mw ) :QWidget(parent, Qt::Tool | Qt::FramelessWindowHint ), #else QmitkRenderWindowMenu::QmitkRenderWindowMenu(QWidget *parent, Qt::WindowFlags f, mitk::BaseRenderer *b, QmitkStdMultiWidget* mw ) :QWidget(parent,f), #endif m_Settings(NULL), m_CrosshairMenu(NULL), m_Layout(0), m_LayoutDesign(0), m_OldLayoutDesign(0), m_FullScreenMode(false), m_Entered(false), m_Hidden(true), m_Renderer(b), m_MultiWidget(mw) { MITK_DEBUG << "creating renderwindow menu on baserenderer " << b; //Create Menu Widget this->CreateMenuWidget(); this->setMinimumWidth(61); //DIRTY.. If you add or remove a button, you need to change the size. this->setMaximumWidth(61); this->setAutoFillBackground( true ); //Else part fixes the render window menu issue on Linux bug but caused bugs on Mac OS and Windows //for Mac OS see bug 3192 //for Windows see bug 12130 //... so Mac OS and Windows must be treated differently: #if defined(Q_OS_MAC) || defined(_WIN32) this->show(); this->setWindowOpacity(0.0f); #else this->setVisible(false); #endif //this->setAttribute( Qt::WA_NoSystemBackground ); //this->setBackgroundRole( QPalette::Dark ); //this->update(); //SetOpacity -- its just posible if the widget is a window. //Windows indicates that the widget is a window, usually with a window system frame and a title bar, //irrespective of whether the widget has a parent or not. /* this->setWindowFlags( Qt::Window | Qt::FramelessWindowHint); */ //this->setAttribute(Qt::WA_TranslucentBackground); //this->setWindowOpacity(0.75); currentCrosshairRotationMode = 0; // for autorotating m_AutoRotationTimer.setInterval( 75 ); connect( &m_AutoRotationTimer, SIGNAL(timeout()), this, SLOT(AutoRotateNextStep()) ); } QmitkRenderWindowMenu::~QmitkRenderWindowMenu() { if( m_AutoRotationTimer.isActive() ) m_AutoRotationTimer.stop(); } void QmitkRenderWindowMenu::CreateMenuWidget() { QHBoxLayout* layout = new QHBoxLayout(this); layout->setAlignment( Qt::AlignRight ); layout->setContentsMargins(1,1,1,1); QSize size( 13, 13 ); m_CrosshairMenu = new QMenu(this); connect( m_CrosshairMenu, SIGNAL( aboutToShow() ), this, SLOT(OnCrossHairMenuAboutToShow()) ); // button for changing rotation mode m_CrosshairModeButton = new QPushButton(this); m_CrosshairModeButton->setMaximumSize(15, 15); m_CrosshairModeButton->setIconSize(size); m_CrosshairModeButton->setFlat( true ); m_CrosshairModeButton->setMenu( m_CrosshairMenu ); m_CrosshairModeButton->setIcon( QIcon( iconCrosshairMode_xpm ) ); layout->addWidget( m_CrosshairModeButton ); //fullScreenButton m_FullScreenButton = new QPushButton(this); m_FullScreenButton->setMaximumSize(15, 15); m_FullScreenButton->setIconSize(size); m_FullScreenButton->setFlat( true ); m_FullScreenButton->setIcon( QIcon( iconFullScreen_xpm )); layout->addWidget( m_FullScreenButton ); //settingsButton m_SettingsButton = new QPushButton(this); m_SettingsButton->setMaximumSize(15, 15); m_SettingsButton->setIconSize(size); m_SettingsButton->setFlat( true ); m_SettingsButton->setIcon( QIcon( iconSettings_xpm )); layout->addWidget( m_SettingsButton ); //Create Connections -- coming soon? connect( m_FullScreenButton, SIGNAL( clicked(bool) ), this, SLOT(OnFullScreenButton(bool)) ); connect( m_SettingsButton, SIGNAL( clicked(bool) ), this, SLOT(OnSettingsButton(bool)) ); } void QmitkRenderWindowMenu::CreateSettingsWidget() { m_Settings = new QMenu(this); m_DefaultLayoutAction = new QAction( "standard layout", m_Settings ); m_DefaultLayoutAction->setDisabled( true ); m_2DImagesUpLayoutAction = new QAction( "2D images top, 3D bottom", m_Settings ); m_2DImagesUpLayoutAction->setDisabled( false ); m_2DImagesLeftLayoutAction = new QAction( "2D images left, 3D right", m_Settings ); m_2DImagesLeftLayoutAction->setDisabled( false ); m_Big3DLayoutAction = new QAction( "Big 3D", m_Settings ); m_Big3DLayoutAction->setDisabled( false ); m_Widget1LayoutAction = new QAction( "Axial plane", m_Settings ); m_Widget1LayoutAction->setDisabled( false ); m_Widget2LayoutAction = new QAction( "Sagittal plane", m_Settings ); m_Widget2LayoutAction->setDisabled( false ); m_Widget3LayoutAction = new QAction( "Coronal plane", m_Settings ); m_Widget3LayoutAction->setDisabled( false ); m_RowWidget3And4LayoutAction = new QAction( "Coronal top, 3D bottom", m_Settings ); m_RowWidget3And4LayoutAction->setDisabled( false ); m_ColumnWidget3And4LayoutAction = new QAction( "Coronal left, 3D right", m_Settings ); m_ColumnWidget3And4LayoutAction->setDisabled( false ); m_SmallUpperWidget2Big3and4LayoutAction = new QAction( "Sagittal top, Coronal n 3D bottom", m_Settings ); m_SmallUpperWidget2Big3and4LayoutAction->setDisabled( false ); m_2x2Dand3DWidgetLayoutAction = new QAction( "Axial n Sagittal left, 3D right", m_Settings ); m_2x2Dand3DWidgetLayoutAction->setDisabled( false ); m_Left2Dand3DRight2DLayoutAction = new QAction( "Axial n 3D left, Sagittal right", m_Settings ); m_Left2Dand3DRight2DLayoutAction->setDisabled( false ); m_Settings->addAction(m_DefaultLayoutAction); m_Settings->addAction(m_2DImagesUpLayoutAction); m_Settings->addAction(m_2DImagesLeftLayoutAction); m_Settings->addAction(m_Big3DLayoutAction); m_Settings->addAction(m_Widget1LayoutAction); m_Settings->addAction(m_Widget2LayoutAction); m_Settings->addAction(m_Widget3LayoutAction); m_Settings->addAction(m_RowWidget3And4LayoutAction); m_Settings->addAction(m_ColumnWidget3And4LayoutAction); m_Settings->addAction(m_SmallUpperWidget2Big3and4LayoutAction); m_Settings->addAction(m_2x2Dand3DWidgetLayoutAction); m_Settings->addAction(m_Left2Dand3DRight2DLayoutAction); m_Settings->setVisible( false ); connect( m_DefaultLayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutToDefault(bool)) ); connect( m_2DImagesUpLayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutTo2DImagesUp(bool)) ); connect( m_2DImagesLeftLayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutTo2DImagesLeft(bool)) ); connect( m_Big3DLayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutToBig3D(bool)) ); connect( m_Widget1LayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutToWidget1(bool)) ); connect( m_Widget2LayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutToWidget2(bool)) ); connect( m_Widget3LayoutAction , SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutToWidget3(bool)) ); connect( m_RowWidget3And4LayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutToRowWidget3And4(bool)) ); connect( m_ColumnWidget3And4LayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutToColumnWidget3And4(bool)) ); connect( m_SmallUpperWidget2Big3and4LayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutToSmallUpperWidget2Big3and4(bool)) ); connect( m_2x2Dand3DWidgetLayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutTo2x2Dand3DWidget(bool)) ); connect( m_Left2Dand3DRight2DLayoutAction, SIGNAL( triggered(bool) ), this, SLOT(OnChangeLayoutToLeft2Dand3DRight2D(bool)) ); } void QmitkRenderWindowMenu::paintEvent( QPaintEvent* /*e*/ ) { QPainter painter(this); QColor semiTransparentColor = Qt::black; semiTransparentColor.setAlpha(255); painter.fillRect(rect(), semiTransparentColor); } void QmitkRenderWindowMenu::SetLayoutIndex( unsigned int layoutIndex ) { m_Layout = layoutIndex; } void QmitkRenderWindowMenu::HideMenu( ) { MITK_DEBUG << "menu hideEvent"; m_Hidden = true; if( ! m_Entered ) { //Else part fixes the render window menu issue on Linux bug but caused bugs on Mac OS and Windows //for Mac OS see bug 3192 //for Windows see bug 12130 //... so Mac OS and Windows must be treated differently: #if defined(Q_OS_MAC) || defined(_WIN32) this->setWindowOpacity(0.0f); #else this->setVisible(false); #endif } } void QmitkRenderWindowMenu::ShowMenu( ) { MITK_DEBUG << "menu showMenu"; m_Hidden = false; //Else part fixes the render window menu issue on Linux bug but caused bugs on Mac OS and Windows //for Mac OS see bug 3192 //for Windows see bug 12130 //... so Mac OS and Windows must be treated differently: #if defined(Q_OS_MAC) || defined(_WIN32) this->setWindowOpacity(1.0f); #else this->setVisible(true); #endif } void QmitkRenderWindowMenu::enterEvent( QEvent * /*e*/ ) { MITK_DEBUG << "menu enterEvent"; m_Entered=true; m_Hidden=false; } void QmitkRenderWindowMenu::DeferredHideMenu( ) { MITK_DEBUG << "menu deferredhidemenu"; if(m_Hidden) { //Else part fixes the render window menu issue on Linux bug but caused bugs on Mac OS and Windows //for Mac OS see bug 3192 //for Windows see bug 12130 //... so Mac OS and Windows must be treated differently: #if defined(Q_OS_MAC) || defined(_WIN32) this->setWindowOpacity(0.0f); #else this->setVisible(false); #endif } // setVisible(false); // setWindowOpacity(0.0f); ///hide(); } void QmitkRenderWindowMenu::leaveEvent( QEvent * /*e*/ ) { MITK_DEBUG << "menu leaveEvent"; smoothHide(); } /* This method is responsible for non fluttering of the renderWindowMenu when mouse cursor moves along the renderWindowMenu*/ void QmitkRenderWindowMenu::smoothHide() { MITK_DEBUG<< "menu leaveEvent"; m_Entered=false; m_Hidden = true; QTimer::singleShot(10,this,SLOT( DeferredHideMenu( ) ) ); } void QmitkRenderWindowMenu::ChangeFullScreenMode( bool state ) { this->OnFullScreenButton( state ); } /// \brief void QmitkRenderWindowMenu::OnFullScreenButton( bool /*checked*/ ) { if( !m_FullScreenMode ) { m_FullScreenMode = true; m_OldLayoutDesign = m_LayoutDesign; switch( m_Layout ) { case AXIAL: { emit SignalChangeLayoutDesign( LAYOUT_AXIAL ); break; } case SAGITTAL: { emit SignalChangeLayoutDesign( LAYOUT_SAGITTAL ); break; } case CORONAL: { emit SignalChangeLayoutDesign( LAYOUT_CORONAL ); break; } case THREE_D: { emit SignalChangeLayoutDesign( LAYOUT_BIG3D ); break; } } //Move Widget and show again this->MoveWidgetToCorrectPos(1.0f); //change icon this->ChangeFullScreenIcon(); } else { m_FullScreenMode = false; emit SignalChangeLayoutDesign( m_OldLayoutDesign ); //Move Widget and show again this->MoveWidgetToCorrectPos(1.0f); //change icon this->ChangeFullScreenIcon(); } DeferredShowMenu( ); } /// \brief void QmitkRenderWindowMenu::OnSettingsButton( bool /*checked*/ ) { if( m_Settings == NULL ) this->CreateSettingsWidget(); QPoint point = this->mapToGlobal( m_SettingsButton->geometry().topLeft() ); m_Settings->setVisible( true ); m_Settings->exec( point ); } void QmitkRenderWindowMenu::OnChangeLayoutTo2DImagesUp(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_2DIMAGEUP; emit SignalChangeLayoutDesign( LAYOUT_2DIMAGEUP ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::OnChangeLayoutTo2DImagesLeft(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_2DIMAGELEFT; emit SignalChangeLayoutDesign( LAYOUT_2DIMAGELEFT ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::OnChangeLayoutToDefault(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_DEFAULT; emit SignalChangeLayoutDesign( LAYOUT_DEFAULT ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::DeferredShowMenu() { MITK_DEBUG << "deferred show menu"; //Else part fixes the render window menu issue on Linux bug but caused bugs on Mac OS and Windows //for Mac OS see bug 3192 //for Windows see bug 12130 //... so Mac OS and Windows must be treated differently: #if defined(Q_OS_MAC) || defined(_WIN32) this->setWindowOpacity(1.0f); #else this->setVisible(true); #endif } void QmitkRenderWindowMenu::OnChangeLayoutToBig3D(bool) { MITK_DEBUG << "OnChangeLayoutToBig3D"; //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_BIG3D; emit SignalChangeLayoutDesign( LAYOUT_BIG3D ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::OnChangeLayoutToWidget1(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_AXIAL; emit SignalChangeLayoutDesign( LAYOUT_AXIAL ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::OnChangeLayoutToWidget2(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_SAGITTAL; emit SignalChangeLayoutDesign( LAYOUT_SAGITTAL ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::OnChangeLayoutToWidget3(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_CORONAL; emit SignalChangeLayoutDesign( LAYOUT_CORONAL ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::OnChangeLayoutToRowWidget3And4(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_ROWWIDGET3AND4; emit SignalChangeLayoutDesign( LAYOUT_ROWWIDGET3AND4 ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::OnChangeLayoutToColumnWidget3And4(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_COLUMNWIDGET3AND4; emit SignalChangeLayoutDesign( LAYOUT_COLUMNWIDGET3AND4 ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::OnChangeLayoutToSmallUpperWidget2Big3and4(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_SMALLUPPERWIDGET2BIGAND4; emit SignalChangeLayoutDesign( LAYOUT_SMALLUPPERWIDGET2BIGAND4 ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::OnChangeLayoutTo2x2Dand3DWidget(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_2X2DAND3DWIDGET; emit SignalChangeLayoutDesign( LAYOUT_2X2DAND3DWIDGET ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::OnChangeLayoutToLeft2Dand3DRight2D(bool) { //set Full Screen Mode to false, if Layout Design was changed by the LayoutDesign_List m_FullScreenMode = false; this->ChangeFullScreenIcon(); m_LayoutDesign = LAYOUT_LEFT2DAND3DRIGHT2D; emit SignalChangeLayoutDesign( LAYOUT_LEFT2DAND3DRIGHT2D ); DeferredShowMenu( ); } void QmitkRenderWindowMenu::UpdateLayoutDesignList( int layoutDesignIndex ) { m_LayoutDesign = layoutDesignIndex; if( m_Settings == NULL ) this->CreateSettingsWidget(); switch( m_LayoutDesign ) { case LAYOUT_DEFAULT: { m_DefaultLayoutAction->setEnabled(false); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_2DIMAGEUP: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(false); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_2DIMAGELEFT: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(false); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_BIG3D: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(false); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_AXIAL: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(false); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_SAGITTAL: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(false); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_CORONAL: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(false); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_2X2DAND3DWIDGET: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(false); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_ROWWIDGET3AND4: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(false); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_COLUMNWIDGET3AND4: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(false); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_SMALLUPPERWIDGET2BIGAND4: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(false); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(true); break; } case LAYOUT_LEFT2DAND3DRIGHT2D: { m_DefaultLayoutAction->setEnabled(true); m_2DImagesUpLayoutAction->setEnabled(true); m_2DImagesLeftLayoutAction->setEnabled(true); m_Big3DLayoutAction->setEnabled(true); m_Widget1LayoutAction->setEnabled(true); m_Widget2LayoutAction->setEnabled(true); m_Widget3LayoutAction->setEnabled(true); m_RowWidget3And4LayoutAction->setEnabled(true); m_ColumnWidget3And4LayoutAction->setEnabled(true); m_SmallUpperWidget2Big3and4LayoutAction->setEnabled(true); m_2x2Dand3DWidgetLayoutAction->setEnabled(true); m_Left2Dand3DRight2DLayoutAction->setEnabled(false); break; } } } #ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU void QmitkRenderWindowMenu::MoveWidgetToCorrectPos(float opacity) #else void QmitkRenderWindowMenu::MoveWidgetToCorrectPos(float /*opacity*/) #endif { #ifdef QMITK_USE_EXTERNAL_RENDERWINDOW_MENU int X=floor( double(this->parentWidget()->width() - this->width() - 8.0) ); int Y=7; QPoint pos = this->parentWidget()->mapToGlobal( QPoint(0,0) ); this->move( X+pos.x(), Y+pos.y() ); if(opacity<0) opacity=0; else if(opacity>1) opacity=1; this->setWindowOpacity(opacity); #else int moveX= floor( double(this->parentWidget()->width() - this->width() - 4.0) ); this->move( moveX, 3 ); this->show(); #endif } void QmitkRenderWindowMenu::ChangeFullScreenIcon() { if( m_FullScreenMode ) { const QIcon icon( iconLeaveFullScreen_xpm ); m_FullScreenButton->setIcon(icon); } else { const QIcon icon( iconFullScreen_xpm ); m_FullScreenButton->setIcon(icon); } } void QmitkRenderWindowMenu::OnCrosshairRotationModeSelected(QAction* action) { MITK_DEBUG << "selected crosshair mode " << action->data().toInt() ; emit ChangeCrosshairRotationMode( action->data().toInt() ); } void QmitkRenderWindowMenu::SetCrossHairVisibility( bool state ) { if(m_Renderer.IsNotNull()) { mitk::DataNode *n; if(this->m_MultiWidget) { n = this->m_MultiWidget->GetWidgetPlane1(); if(n) n->SetVisibility(state); n = this->m_MultiWidget->GetWidgetPlane2(); if(n) n->SetVisibility(state); n = this->m_MultiWidget->GetWidgetPlane3(); if(n) n->SetVisibility(state); m_Renderer->GetRenderingManager()->RequestUpdateAll(); } } } void QmitkRenderWindowMenu::OnTSNumChanged(int num) { MITK_DEBUG << "Thickslices num: " << num << " on renderer " << m_Renderer.GetPointer(); if(m_Renderer.IsNotNull()) { if(num==0) { m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); + m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( false ) ); } else { m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 1 ) ); m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); - m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( num > 1 ) ); + m_Renderer->GetCurrentWorldPlaneGeometryNode()->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( true ) ); } m_TSLabel->setText(QString::number(num*2+1)); m_Renderer->SendUpdateSlice(); m_Renderer->GetRenderingManager()->RequestUpdateAll(); } } void QmitkRenderWindowMenu::OnCrossHairMenuAboutToShow() { QMenu *crosshairModesMenu = m_CrosshairMenu; crosshairModesMenu->clear(); QAction* resetViewAction = new QAction(crosshairModesMenu); resetViewAction->setText("Reset view"); crosshairModesMenu->addAction( resetViewAction ); connect( resetViewAction, SIGNAL(triggered()), this, SIGNAL(ResetView())); // Show hide crosshairs { bool currentState = true; if(m_Renderer.IsNotNull()) { mitk::DataStorage *ds=m_Renderer->GetDataStorage(); mitk::DataNode *n; if(ds) { n = this->m_MultiWidget->GetWidgetPlane1(); if(n) { bool v; if(n->GetVisibility(v,0)) currentState&=v; } n = this->m_MultiWidget->GetWidgetPlane2(); if(n) { bool v; if(n->GetVisibility(v,0)) currentState&=v; } n = this->m_MultiWidget->GetWidgetPlane3(); if(n) { bool v; if(n->GetVisibility(v,0)) currentState&=v; } } } QAction* showHideCrosshairVisibilityAction = new QAction(crosshairModesMenu); showHideCrosshairVisibilityAction->setText("Show crosshair"); showHideCrosshairVisibilityAction->setCheckable(true); showHideCrosshairVisibilityAction->setChecked(currentState); crosshairModesMenu->addAction( showHideCrosshairVisibilityAction ); connect( showHideCrosshairVisibilityAction, SIGNAL(toggled(bool)), this, SLOT(SetCrossHairVisibility(bool))); } // Rotation mode { QAction* rotationGroupSeparator = new QAction(crosshairModesMenu); rotationGroupSeparator->setSeparator(true); rotationGroupSeparator->setText("Rotation mode"); crosshairModesMenu->addAction( rotationGroupSeparator ); QActionGroup* rotationModeActionGroup = new QActionGroup(crosshairModesMenu); rotationModeActionGroup->setExclusive(true); QAction* noCrosshairRotation = new QAction(crosshairModesMenu); noCrosshairRotation->setActionGroup(rotationModeActionGroup); noCrosshairRotation->setText("No crosshair rotation"); noCrosshairRotation->setCheckable(true); noCrosshairRotation->setChecked(currentCrosshairRotationMode==0); noCrosshairRotation->setData( 0 ); crosshairModesMenu->addAction( noCrosshairRotation ); QAction* singleCrosshairRotation = new QAction(crosshairModesMenu); singleCrosshairRotation->setActionGroup(rotationModeActionGroup); singleCrosshairRotation->setText("Crosshair rotation"); singleCrosshairRotation->setCheckable(true); singleCrosshairRotation->setChecked(currentCrosshairRotationMode==1); singleCrosshairRotation->setData( 1 ); crosshairModesMenu->addAction( singleCrosshairRotation ); QAction* coupledCrosshairRotation = new QAction(crosshairModesMenu); coupledCrosshairRotation->setActionGroup(rotationModeActionGroup); coupledCrosshairRotation->setText("Coupled crosshair rotation"); coupledCrosshairRotation->setCheckable(true); coupledCrosshairRotation->setChecked(currentCrosshairRotationMode==2); coupledCrosshairRotation->setData( 2 ); crosshairModesMenu->addAction( coupledCrosshairRotation ); QAction* swivelMode = new QAction(crosshairModesMenu); swivelMode->setActionGroup(rotationModeActionGroup); swivelMode->setText("Swivel mode"); swivelMode->setCheckable(true); swivelMode->setChecked(currentCrosshairRotationMode==3); swivelMode->setData( 3 ); crosshairModesMenu->addAction( swivelMode ); connect( rotationModeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(OnCrosshairRotationModeSelected(QAction*)) ); } // auto rotation support if( m_Renderer.IsNotNull() && m_Renderer->GetMapperID() == mitk::BaseRenderer::Standard3D ) { QAction* autoRotationGroupSeparator = new QAction(crosshairModesMenu); autoRotationGroupSeparator->setSeparator(true); crosshairModesMenu->addAction( autoRotationGroupSeparator ); QAction* autoRotationAction = crosshairModesMenu->addAction( "Auto Rotation" ); autoRotationAction->setCheckable(true); autoRotationAction->setChecked( m_AutoRotationTimer.isActive() ); connect( autoRotationAction, SIGNAL(triggered()), this, SLOT(OnAutoRotationActionTriggered()) ); } // Thickslices support if( m_Renderer.IsNotNull() && m_Renderer->GetMapperID() == mitk::BaseRenderer::Standard2D ) { QAction* thickSlicesGroupSeparator = new QAction(crosshairModesMenu); thickSlicesGroupSeparator->setSeparator(true); thickSlicesGroupSeparator->setText("ThickSlices mode"); crosshairModesMenu->addAction( thickSlicesGroupSeparator ); QActionGroup* thickSlicesActionGroup = new QActionGroup(crosshairModesMenu); thickSlicesActionGroup->setExclusive(true); int currentMode = 0; { mitk::ResliceMethodProperty::Pointer m = dynamic_cast(m_Renderer->GetCurrentWorldPlaneGeometryNode()->GetProperty( "reslice.thickslices" )); if( m.IsNotNull() ) currentMode = m->GetValueAsId(); } int currentNum = 1; { mitk::IntProperty::Pointer m = dynamic_cast(m_Renderer->GetCurrentWorldPlaneGeometryNode()->GetProperty( "reslice.thickslices.num" )); if( m.IsNotNull() ) { currentNum = m->GetValue(); if(currentNum < 1) currentNum = 1; if(currentNum > 10) currentNum = 10; } } if(currentMode==0) currentNum=0; QSlider *m_TSSlider = new QSlider(crosshairModesMenu); m_TSSlider->setMinimum(0); m_TSSlider->setMaximum(9); m_TSSlider->setValue(currentNum); m_TSSlider->setOrientation(Qt::Horizontal); connect( m_TSSlider, SIGNAL( valueChanged(int) ), this, SLOT( OnTSNumChanged(int) ) ); QHBoxLayout* _TSLayout = new QHBoxLayout; _TSLayout->setContentsMargins(4,4,4,4); _TSLayout->addWidget(new QLabel("TS: ")); _TSLayout->addWidget(m_TSSlider); _TSLayout->addWidget(m_TSLabel=new QLabel(QString::number(currentNum*2+1),this)); QWidget* _TSWidget = new QWidget; _TSWidget->setLayout(_TSLayout); QWidgetAction *m_TSSliderAction = new QWidgetAction(crosshairModesMenu); m_TSSliderAction->setDefaultWidget(_TSWidget); crosshairModesMenu->addAction(m_TSSliderAction); } } void QmitkRenderWindowMenu::NotifyNewWidgetPlanesMode( int mode ) { currentCrosshairRotationMode = mode; } void QmitkRenderWindowMenu::OnAutoRotationActionTriggered() { if(m_AutoRotationTimer.isActive()) { m_AutoRotationTimer.stop(); m_Renderer->GetCameraRotationController()->GetSlice()->PingPongOff(); } else { m_Renderer->GetCameraRotationController()->GetSlice()->PingPongOn(); m_AutoRotationTimer.start(); } } void QmitkRenderWindowMenu::AutoRotateNextStep() { if(m_Renderer->GetCameraRotationController()) m_Renderer->GetCameraRotationController()->GetSlice()->Next(); } diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp index 120c84e8ca..cb424b79af 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.cpp @@ -1,1862 +1,1896 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "QmitkControlVisualizationPropertiesView.h" #include "mitkNodePredicateDataType.h" #include "mitkDataNodeObject.h" #include "mitkOdfNormalizationMethodProperty.h" #include "mitkOdfScaleByProperty.h" #include "mitkResliceMethodProperty.h" #include "mitkRenderingManager.h" #include "mitkTbssImage.h" #include "mitkPlanarFigure.h" #include "mitkFiberBundleX.h" #include "QmitkDataStorageComboBox.h" #include "QmitkStdMultiWidget.h" #include "mitkFiberBundleInteractor.h" #include "mitkPlanarFigureInteractor.h" #include #include #include #include #include "mitkGlobalInteraction.h" #include "usModuleRegistry.h" #include "mitkPlaneGeometry.h" #include "berryIWorkbenchWindow.h" #include "berryIWorkbenchPage.h" #include "berryISelectionService.h" #include "berryConstants.h" #include "berryPlatformUI.h" #include "itkRGBAPixel.h" #include #include "qwidgetaction.h" #include "qcolordialog.h" #include #define ROUND(a) ((a)>0 ? (int)((a)+0.5) : -(int)(0.5-(a))) static bool DetermineAffectedImageSlice( const mitk::Image* image, const mitk::PlaneGeometry* plane, int& affectedDimension, int& affectedSlice ) { - assert(image); - assert(plane); - - // compare normal of plane to the three axis vectors of the image - mitk::Vector3D normal = plane->GetNormal(); - mitk::Vector3D imageNormal0 = image->GetSlicedGeometry()->GetAxisVector(0); - mitk::Vector3D imageNormal1 = image->GetSlicedGeometry()->GetAxisVector(1); - mitk::Vector3D imageNormal2 = image->GetSlicedGeometry()->GetAxisVector(2); - - normal.Normalize(); - imageNormal0.Normalize(); - imageNormal1.Normalize(); - imageNormal2.Normalize(); - - imageNormal0.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal0.GetVnlVector()) ); - imageNormal1.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal1.GetVnlVector()) ); - imageNormal2.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal2.GetVnlVector()) ); - - double eps( 0.00001 ); - // axial - if ( imageNormal2.GetNorm() <= eps ) - { - affectedDimension = 2; - } - // sagittal - else if ( imageNormal1.GetNorm() <= eps ) - { - affectedDimension = 1; - } - // frontal - else if ( imageNormal0.GetNorm() <= eps ) - { - affectedDimension = 0; - } - else - { - affectedDimension = -1; // no idea - return false; - } - - // determine slice number in image - mitk::BaseGeometry* imageGeometry = image->GetGeometry(0); - mitk::Point3D testPoint = imageGeometry->GetCenter(); - mitk::Point3D projectedPoint; - plane->Project( testPoint, projectedPoint ); - - mitk::Point3D indexPoint; - - imageGeometry->WorldToIndex( projectedPoint, indexPoint ); - affectedSlice = ROUND( indexPoint[affectedDimension] ); - MITK_DEBUG << "indexPoint " << indexPoint << " affectedDimension " << affectedDimension << " affectedSlice " << affectedSlice; - - // check if this index is still within the image - if ( affectedSlice < 0 || affectedSlice >= static_cast(image->GetDimension(affectedDimension)) ) return false; - - return true; -} - -const std::string QmitkControlVisualizationPropertiesView::VIEW_ID = "org.mitk.views.controlvisualizationpropertiesview"; - -using namespace berry; - -struct CvpSelListener : ISelectionListener -{ - - berryObjectMacro(CvpSelListener); - - CvpSelListener(QmitkControlVisualizationPropertiesView* view) - { - m_View = view; - } - - void ApplySettings(mitk::DataNode::Pointer node) - { - bool tex_int; - node->GetBoolProperty("texture interpolation", tex_int); - if(tex_int) + assert(image); + assert(plane); + + // compare normal of plane to the three axis vectors of the image + mitk::Vector3D normal = plane->GetNormal(); + mitk::Vector3D imageNormal0 = image->GetSlicedGeometry()->GetAxisVector(0); + mitk::Vector3D imageNormal1 = image->GetSlicedGeometry()->GetAxisVector(1); + mitk::Vector3D imageNormal2 = image->GetSlicedGeometry()->GetAxisVector(2); + + normal.Normalize(); + imageNormal0.Normalize(); + imageNormal1.Normalize(); + imageNormal2.Normalize(); + + imageNormal0.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal0.GetVnlVector()) ); + imageNormal1.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal1.GetVnlVector()) ); + imageNormal2.SetVnlVector( vnl_cross_3d(normal.GetVnlVector(),imageNormal2.GetVnlVector()) ); + + double eps( 0.00001 ); + // axial + if ( imageNormal2.GetNorm() <= eps ) + { + affectedDimension = 2; + } + // sagittal + else if ( imageNormal1.GetNorm() <= eps ) { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); - m_View->m_Controls->m_TextureIntON->setChecked(true); - m_View->m_TexIsOn = true; + affectedDimension = 1; + } + // frontal + else if ( imageNormal0.GetNorm() <= eps ) + { + affectedDimension = 0; } else { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); - m_View->m_Controls->m_TextureIntON->setChecked(false); - m_View->m_TexIsOn = false; + affectedDimension = -1; // no idea + return false; } - int val; - node->GetIntProperty("ShowMaxNumber", val); - m_View->m_Controls->m_ShowMaxNumber->setValue(val); - - m_View->m_Controls->m_NormalizationDropdown->setCurrentIndex(dynamic_cast(node->GetProperty("Normalization"))->GetValueAsId()); + // determine slice number in image + mitk::BaseGeometry* imageGeometry = image->GetGeometry(0); + mitk::Point3D testPoint = imageGeometry->GetCenter(); + mitk::Point3D projectedPoint; + plane->Project( testPoint, projectedPoint ); - float fval; - node->GetFloatProperty("Scaling",fval); - m_View->m_Controls->m_ScalingFactor->setValue(fval); + mitk::Point3D indexPoint; - m_View->m_Controls->m_AdditionalScaling->setCurrentIndex(dynamic_cast(node->GetProperty("ScaleBy"))->GetValueAsId()); + imageGeometry->WorldToIndex( projectedPoint, indexPoint ); + affectedSlice = ROUND( indexPoint[affectedDimension] ); + MITK_DEBUG << "indexPoint " << indexPoint << " affectedDimension " << affectedDimension << " affectedSlice " << affectedSlice; - node->GetFloatProperty("IndexParam1",fval); - m_View->m_Controls->m_IndexParam1->setValue(fval); + // check if this index is still within the image + if ( affectedSlice < 0 || affectedSlice >= static_cast(image->GetDimension(affectedDimension)) ) return false; - node->GetFloatProperty("IndexParam2",fval); - m_View->m_Controls->m_IndexParam2->setValue(fval); - } + return true; +} - void DoSelectionChanged(ISelection::ConstPointer selection) - { - // save current selection in member variable - m_View->m_CurrentSelection = selection.Cast(); +const std::string QmitkControlVisualizationPropertiesView::VIEW_ID = "org.mitk.views.controlvisualizationpropertiesview"; - m_View->m_Controls->m_VisibleOdfsON_T->setVisible(false); - m_View->m_Controls->m_VisibleOdfsON_S->setVisible(false); - m_View->m_Controls->m_VisibleOdfsON_C->setVisible(false); - m_View->m_Controls->m_TextureIntON->setVisible(false); +using namespace berry; - m_View->m_Controls->m_ImageControlsFrame->setVisible(false); - m_View->m_Controls->m_PlanarFigureControlsFrame->setVisible(false); - m_View->m_Controls->m_BundleControlsFrame->setVisible(false); - m_View->m_SelectedNode = 0; +struct CvpSelListener : ISelectionListener +{ - if(m_View->m_CurrentSelection.IsNull()) - return; + berryObjectMacro(CvpSelListener); - if(m_View->m_CurrentSelection->Size() == 1) + CvpSelListener(QmitkControlVisualizationPropertiesView* view) { - mitk::DataNodeObject::Pointer nodeObj = m_View->m_CurrentSelection->Begin()->Cast(); - if(nodeObj.IsNotNull()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - - // check if node has data, - // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV - mitk::BaseData* nodeData = node->GetData(); + m_View = view; + } - if(nodeData != NULL ) + void ApplySettings(mitk::DataNode::Pointer node) + { + bool tex_int; + node->GetBoolProperty("texture interpolation", tex_int); + if(tex_int) { - if(dynamic_cast(nodeData) != 0) - { - m_View->m_Controls->m_PlanarFigureControlsFrame->setVisible(true); - m_View->m_SelectedNode = node; - - float val; - node->GetFloatProperty("planarfigure.line.width", val); - m_View->m_Controls->m_PFWidth->setValue((int)(val*10.0)); - - QString label = "Width %1"; - label = label.arg(val); - m_View->m_Controls->label_pfwidth->setText(label); - - float color[3]; - node->GetColor( color, NULL, "planarfigure.default.line.color"); - QString styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color[0]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[1]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[2]*255.0)); - styleSheet.append(")"); - m_View->m_Controls->m_PFColor->setAutoFillBackground(true); - m_View->m_Controls->m_PFColor->setStyleSheet(styleSheet); - - node->GetColor( color, NULL, "color"); - styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color[0]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[1]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[2]*255.0)); - styleSheet.append(")"); - - m_View->PlanarFigureFocus(); - } - - if(dynamic_cast(nodeData) != 0) - { - m_View->m_Controls->m_BundleControlsFrame->setVisible(true); - m_View->m_SelectedNode = node; - - if(m_View->m_CurrentPickingNode != 0 && node.GetPointer() != m_View->m_CurrentPickingNode) - { - m_View->m_Controls->m_Crosshair->setEnabled(false); - } - else - { - m_View->m_Controls->m_Crosshair->setEnabled(true); - } + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); + m_View->m_Controls->m_TextureIntON->setChecked(true); + m_View->m_TexIsOn = true; + } + else + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); + m_View->m_Controls->m_TextureIntON->setChecked(false); + m_View->m_TexIsOn = false; + } - float val; - node->GetFloatProperty("TubeRadius", val); - m_View->m_Controls->m_TubeRadius->setValue((int)(val * 100.0)); + int val; + node->GetIntProperty("ShowMaxNumber", val); + m_View->m_Controls->m_ShowMaxNumber->setValue(val); - QString label = "Radius %1"; - label = label.arg(val); - m_View->m_Controls->label_tuberadius->setText(label); + m_View->m_Controls->m_NormalizationDropdown->setCurrentIndex(dynamic_cast(node->GetProperty("Normalization"))->GetValueAsId()); - int width; - node->GetIntProperty("LineWidth", width); - m_View->m_Controls->m_LineWidth->setValue(width); + float fval; + node->GetFloatProperty("Scaling",fval); + m_View->m_Controls->m_ScalingFactor->setValue(fval); - label = "Width %1"; - label = label.arg(width); - m_View->m_Controls->label_linewidth->setText(label); + m_View->m_Controls->m_AdditionalScaling->setCurrentIndex(dynamic_cast(node->GetProperty("ScaleBy"))->GetValueAsId()); - float range; - node->GetFloatProperty("Fiber2DSliceThickness",range); - mitk::FiberBundleX::Pointer fib = dynamic_cast(node->GetData()); - mitk::BaseGeometry::Pointer geo = fib->GetGeometry(); - mitk::ScalarType max = geo->GetExtentInMM(0); - max = std::max(max, geo->GetExtentInMM(1)); - max = std::max(max, geo->GetExtentInMM(2)); + node->GetFloatProperty("IndexParam1",fval); + m_View->m_Controls->m_IndexParam1->setValue(fval); - m_View->m_Controls->m_FiberThicknessSlider->setMaximum(max * 10); + node->GetFloatProperty("IndexParam2",fval); + m_View->m_Controls->m_IndexParam2->setValue(fval); + } - m_View->m_Controls->m_FiberThicknessSlider->setValue(range * 10); + void DoSelectionChanged(ISelection::ConstPointer selection) + { + // save current selection in member variable + m_View->m_CurrentSelection = selection.Cast(); - } + m_View->m_Controls->m_VisibleOdfsON_T->setVisible(false); + m_View->m_Controls->m_VisibleOdfsON_S->setVisible(false); + m_View->m_Controls->m_VisibleOdfsON_C->setVisible(false); + m_View->m_Controls->m_TextureIntON->setVisible(false); - } // check node data != NULL - } - } + m_View->m_Controls->m_ImageControlsFrame->setVisible(false); + m_View->m_Controls->m_PlanarFigureControlsFrame->setVisible(false); + m_View->m_Controls->m_BundleControlsFrame->setVisible(false); + m_View->m_SelectedNode = 0; - if(m_View->m_CurrentSelection->Size() > 0 && m_View->m_SelectedNode == 0) - { - m_View->m_Controls->m_ImageControlsFrame->setVisible(true); - - bool foundDiffusionImage = false; - bool foundQBIVolume = false; - bool foundTensorVolume = false; - bool foundImage = false; - bool foundMultipleOdfImages = false; - bool foundRGBAImage = false; - bool foundTbssImage = false; - - // do something with the selected items - if(m_View->m_CurrentSelection) - { - // iterate selection - for (IStructuredSelection::iterator i = m_View->m_CurrentSelection->Begin(); - i != m_View->m_CurrentSelection->End(); ++i) + if(m_View->m_CurrentSelection.IsNull()) + return; + + if(m_View->m_CurrentSelection->Size() == 1) { + mitk::DataNodeObject::Pointer nodeObj = m_View->m_CurrentSelection->Begin()->Cast(); + if(nodeObj.IsNotNull()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - // extract datatree node - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + // check if node has data, + // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV + mitk::BaseData* nodeData = node->GetData(); - mitk::BaseData* nodeData = node->GetData(); + if(nodeData != NULL ) + { + if(dynamic_cast(nodeData) != 0) + { + m_View->m_Controls->m_PlanarFigureControlsFrame->setVisible(true); + m_View->m_SelectedNode = node; + + float val; + node->GetFloatProperty("planarfigure.line.width", val); + m_View->m_Controls->m_PFWidth->setValue((int)(val*10.0)); + + QString label = "Width %1"; + label = label.arg(val); + m_View->m_Controls->label_pfwidth->setText(label); + + float color[3]; + node->GetColor( color, NULL, "planarfigure.default.line.color"); + QString styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color[0]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[1]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[2]*255.0)); + styleSheet.append(")"); + m_View->m_Controls->m_PFColor->setAutoFillBackground(true); + m_View->m_Controls->m_PFColor->setStyleSheet(styleSheet); + + node->GetColor( color, NULL, "color"); + styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color[0]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[1]*255.0)); + styleSheet.append(","); + styleSheet.append(QString::number(color[2]*255.0)); + styleSheet.append(")"); + + m_View->PlanarFigureFocus(); + } + + if(dynamic_cast(nodeData) != 0) + { + m_View->m_Controls->m_BundleControlsFrame->setVisible(true); + m_View->m_SelectedNode = node; + + if(m_View->m_CurrentPickingNode != 0 && node.GetPointer() != m_View->m_CurrentPickingNode) + { + m_View->m_Controls->m_Crosshair->setEnabled(false); + } + else + { + m_View->m_Controls->m_Crosshair->setEnabled(true); + } + + float val; + node->GetFloatProperty("TubeRadius", val); + m_View->m_Controls->m_TubeRadius->setValue((int)(val * 100.0)); + + QString label = "Radius %1"; + label = label.arg(val); + m_View->m_Controls->label_tuberadius->setText(label); + + int width; + node->GetIntProperty("LineWidth", width); + m_View->m_Controls->m_LineWidth->setValue(width); + + label = "Width %1"; + label = label.arg(width); + m_View->m_Controls->label_linewidth->setText(label); + + float range; + node->GetFloatProperty("Fiber2DSliceThickness",range); + mitk::FiberBundleX::Pointer fib = dynamic_cast(node->GetData()); + mitk::BaseGeometry::Pointer geo = fib->GetGeometry(); + mitk::ScalarType max = geo->GetExtentInMM(0); + max = std::max(max, geo->GetExtentInMM(1)); + max = std::max(max, geo->GetExtentInMM(2)); + + m_View->m_Controls->m_FiberThicknessSlider->setMaximum(max * 10); + + m_View->m_Controls->m_FiberThicknessSlider->setValue(range * 10); + + } + + } // check node data != NULL + } + } - if(nodeData != NULL ) + if(m_View->m_CurrentSelection->Size() > 0 && m_View->m_SelectedNode == 0) + { + m_View->m_Controls->m_ImageControlsFrame->setVisible(true); + + bool foundDiffusionImage = false; + bool foundQBIVolume = false; + bool foundTensorVolume = false; + bool foundImage = false; + bool foundMultipleOdfImages = false; + bool foundRGBAImage = false; + bool foundTbssImage = false; + + // do something with the selected items + if(m_View->m_CurrentSelection) { - // only look at interesting types - if(QString("DiffusionImage").compare(nodeData->GetNameOfClass())==0) - { - foundDiffusionImage = true; - bool tex_int; - node->GetBoolProperty("texture interpolation", tex_int); - if(tex_int) - { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); - m_View->m_Controls->m_TextureIntON->setChecked(true); - m_View->m_TexIsOn = true; - } - else + // iterate selection + for (IStructuredSelection::iterator i = m_View->m_CurrentSelection->Begin(); + i != m_View->m_CurrentSelection->End(); ++i) { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); - m_View->m_Controls->m_TextureIntON->setChecked(false); - m_View->m_TexIsOn = false; - } - int val; - node->GetIntProperty("DisplayChannel", val); - m_View->m_Controls->m_DisplayIndex->setValue(val); - m_View->m_Controls->m_DisplayIndexSpinBox->setValue(val); - - QString label = "Channel %1"; - label = label.arg(val); - m_View->m_Controls->label_channel->setText(label); - - int maxVal = (dynamic_cast* >(nodeData))->GetVectorImage()->GetVectorLength(); - m_View->m_Controls->m_DisplayIndex->setMaximum(maxVal-1); - m_View->m_Controls->m_DisplayIndexSpinBox->setMaximum(maxVal-1); - } - - if(QString("TbssImage").compare(nodeData->GetNameOfClass())==0) - { - foundTbssImage = true; - bool tex_int; - node->GetBoolProperty("texture interpolation", tex_int); - if(tex_int) - { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); - m_View->m_Controls->m_TextureIntON->setChecked(true); - m_View->m_TexIsOn = true; - } - else - { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); - m_View->m_Controls->m_TextureIntON->setChecked(false); - m_View->m_TexIsOn = false; - } - int val; - node->GetIntProperty("DisplayChannel", val); - m_View->m_Controls->m_DisplayIndex->setValue(val); - m_View->m_Controls->m_DisplayIndexSpinBox->setValue(val); - - QString label = "Channel %1"; - label = label.arg(val); - m_View->m_Controls->label_channel->setText(label); - - int maxVal = (dynamic_cast(nodeData))->GetImage()->GetVectorLength(); - m_View->m_Controls->m_DisplayIndex->setMaximum(maxVal-1); - m_View->m_Controls->m_DisplayIndexSpinBox->setMaximum(maxVal-1); - } - - - else if(QString("QBallImage").compare(nodeData->GetNameOfClass())==0) - { - foundMultipleOdfImages = foundQBIVolume || foundTensorVolume; - foundQBIVolume = true; - ApplySettings(node); - } - - else if(QString("TensorImage").compare(nodeData->GetNameOfClass())==0) - { - foundMultipleOdfImages = foundQBIVolume || foundTensorVolume; - foundTensorVolume = true; - ApplySettings(node); - } - - else if(QString("Image").compare(nodeData->GetNameOfClass())==0) - { - foundImage = true; - mitk::Image::Pointer img = dynamic_cast(nodeData); - if(img.IsNotNull() - && img->GetPixelType().GetPixelType() == itk::ImageIOBase::RGBA - && img->GetPixelType().GetComponentType() == itk::ImageIOBase::UCHAR ) - { - foundRGBAImage = true; - } - bool tex_int; - node->GetBoolProperty("texture interpolation", tex_int); - if(tex_int) - { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); - m_View->m_Controls->m_TextureIntON->setChecked(true); - m_View->m_TexIsOn = true; - } - else - { - m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); - m_View->m_Controls->m_TextureIntON->setChecked(false); - m_View->m_TexIsOn = false; + // extract datatree node + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + + mitk::BaseData* nodeData = node->GetData(); + + if(nodeData != NULL ) + { + // only look at interesting types + if(QString("DiffusionImage").compare(nodeData->GetNameOfClass())==0) + { + foundDiffusionImage = true; + bool tex_int; + node->GetBoolProperty("texture interpolation", tex_int); + if(tex_int) + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); + m_View->m_Controls->m_TextureIntON->setChecked(true); + m_View->m_TexIsOn = true; + } + else + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); + m_View->m_Controls->m_TextureIntON->setChecked(false); + m_View->m_TexIsOn = false; + } + int val; + node->GetIntProperty("DisplayChannel", val); + m_View->m_Controls->m_DisplayIndex->setValue(val); + m_View->m_Controls->m_DisplayIndexSpinBox->setValue(val); + + QString label = "Channel %1"; + label = label.arg(val); + m_View->m_Controls->label_channel->setText(label); + + int maxVal = (dynamic_cast* >(nodeData))->GetVectorImage()->GetVectorLength(); + m_View->m_Controls->m_DisplayIndex->setMaximum(maxVal-1); + m_View->m_Controls->m_DisplayIndexSpinBox->setMaximum(maxVal-1); + } + + if(QString("TbssImage").compare(nodeData->GetNameOfClass())==0) + { + foundTbssImage = true; + bool tex_int; + node->GetBoolProperty("texture interpolation", tex_int); + if(tex_int) + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); + m_View->m_Controls->m_TextureIntON->setChecked(true); + m_View->m_TexIsOn = true; + } + else + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); + m_View->m_Controls->m_TextureIntON->setChecked(false); + m_View->m_TexIsOn = false; + } + int val; + node->GetIntProperty("DisplayChannel", val); + m_View->m_Controls->m_DisplayIndex->setValue(val); + m_View->m_Controls->m_DisplayIndexSpinBox->setValue(val); + + QString label = "Channel %1"; + label = label.arg(val); + m_View->m_Controls->label_channel->setText(label); + + int maxVal = (dynamic_cast(nodeData))->GetImage()->GetVectorLength(); + m_View->m_Controls->m_DisplayIndex->setMaximum(maxVal-1); + m_View->m_Controls->m_DisplayIndexSpinBox->setMaximum(maxVal-1); + } + + + else if(QString("QBallImage").compare(nodeData->GetNameOfClass())==0) + { + foundMultipleOdfImages = foundQBIVolume || foundTensorVolume; + foundQBIVolume = true; + ApplySettings(node); + } + + else if(QString("TensorImage").compare(nodeData->GetNameOfClass())==0) + { + foundMultipleOdfImages = foundQBIVolume || foundTensorVolume; + foundTensorVolume = true; + ApplySettings(node); + } + + else if(QString("Image").compare(nodeData->GetNameOfClass())==0) + { + foundImage = true; + mitk::Image::Pointer img = dynamic_cast(nodeData); + if(img.IsNotNull() + && img->GetPixelType().GetPixelType() == itk::ImageIOBase::RGBA + && img->GetPixelType().GetComponentType() == itk::ImageIOBase::UCHAR ) + { + foundRGBAImage = true; + } + + bool tex_int; + node->GetBoolProperty("texture interpolation", tex_int); + if(tex_int) + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexON); + m_View->m_Controls->m_TextureIntON->setChecked(true); + m_View->m_TexIsOn = true; + } + else + { + m_View->m_Controls->m_TextureIntON->setIcon(*m_View->m_IconTexOFF); + m_View->m_Controls->m_TextureIntON->setChecked(false); + m_View->m_TexIsOn = false; + } + } + + } // END CHECK node != NULL + } } - } - - } // END CHECK node != NULL - } - } - } + } - m_View->m_FoundSingleOdfImage = (foundQBIVolume || foundTensorVolume) - && !foundMultipleOdfImages; - m_View->m_Controls->m_NumberGlyphsFrame->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_FoundSingleOdfImage = (foundQBIVolume || foundTensorVolume) + && !foundMultipleOdfImages; + m_View->m_Controls->m_NumberGlyphsFrame->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_NormalizationDropdown->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->label->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_ScalingFactor->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_AdditionalScaling->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_NormalizationScalingFrame->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_NormalizationDropdown->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->label->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_ScalingFactor->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_AdditionalScaling->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_NormalizationScalingFrame->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->OpacMinFrame->setVisible(foundRGBAImage || m_View->m_FoundSingleOdfImage); + m_View->m_Controls->OpacMinFrame->setVisible(foundRGBAImage || m_View->m_FoundSingleOdfImage); - // changed for SPIE paper, Principle curvature scaling - //m_View->m_Controls->params_frame->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->params_frame->setVisible(false); + // changed for SPIE paper, Principle curvature scaling + //m_View->m_Controls->params_frame->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->params_frame->setVisible(false); - m_View->m_Controls->m_VisibleOdfsON_T->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_VisibleOdfsON_S->setVisible(m_View->m_FoundSingleOdfImage); - m_View->m_Controls->m_VisibleOdfsON_C->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_VisibleOdfsON_T->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_VisibleOdfsON_S->setVisible(m_View->m_FoundSingleOdfImage); + m_View->m_Controls->m_VisibleOdfsON_C->setVisible(m_View->m_FoundSingleOdfImage); - bool foundAnyImage = foundDiffusionImage || - foundQBIVolume || foundTensorVolume || foundImage || foundTbssImage; + bool foundAnyImage = foundDiffusionImage || + foundQBIVolume || foundTensorVolume || foundImage || foundTbssImage; - m_View->m_Controls->m_Reinit->setVisible(foundAnyImage); - m_View->m_Controls->m_TextureIntON->setVisible(foundAnyImage); - m_View->m_Controls->m_TSMenu->setVisible(foundAnyImage); + m_View->m_Controls->m_Reinit->setVisible(foundAnyImage); + m_View->m_Controls->m_TextureIntON->setVisible(foundAnyImage); + m_View->m_Controls->m_TSMenu->setVisible(foundAnyImage); + } } - } - void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection) - { - // check, if selection comes from datamanager - if (part) + void SelectionChanged(IWorkbenchPart::Pointer part, ISelection::ConstPointer selection) { - QString partname(part->GetPartName().c_str()); - if(partname.compare("Data Manager")==0) - { + // check, if selection comes from datamanager + if (part) + { + QString partname(part->GetPartName().c_str()); + if(partname.compare("Data Manager")==0) + { - // apply selection - DoSelectionChanged(selection); + // apply selection + DoSelectionChanged(selection); - } + } + } } - } - QmitkControlVisualizationPropertiesView* m_View; + QmitkControlVisualizationPropertiesView* m_View; }; QmitkControlVisualizationPropertiesView::QmitkControlVisualizationPropertiesView() - : QmitkFunctionality(), - m_Controls(NULL), - m_MultiWidget(NULL), - m_NodeUsedForOdfVisualization(NULL), - m_IconTexOFF(new QIcon(":/QmitkDiffusionImaging/texIntOFFIcon.png")), - m_IconTexON(new QIcon(":/QmitkDiffusionImaging/texIntONIcon.png")), - m_IconGlyOFF_T(new QIcon(":/QmitkDiffusionImaging/glyphsoff_T.png")), - m_IconGlyON_T(new QIcon(":/QmitkDiffusionImaging/glyphson_T.png")), - m_IconGlyOFF_C(new QIcon(":/QmitkDiffusionImaging/glyphsoff_C.png")), - m_IconGlyON_C(new QIcon(":/QmitkDiffusionImaging/glyphson_C.png")), - m_IconGlyOFF_S(new QIcon(":/QmitkDiffusionImaging/glyphsoff_S.png")), - m_IconGlyON_S(new QIcon(":/QmitkDiffusionImaging/glyphson_S.png")), - m_CurrentSelection(0), - m_CurrentPickingNode(0), - m_GlyIsOn_S(false), - m_GlyIsOn_C(false), - m_GlyIsOn_T(false), - m_FiberBundleObserverTag(0), - m_Color(NULL) + : QmitkFunctionality(), + m_Controls(NULL), + m_MultiWidget(NULL), + m_NodeUsedForOdfVisualization(NULL), + m_IconTexOFF(new QIcon(":/QmitkDiffusionImaging/texIntOFFIcon.png")), + m_IconTexON(new QIcon(":/QmitkDiffusionImaging/texIntONIcon.png")), + m_IconGlyOFF_T(new QIcon(":/QmitkDiffusionImaging/glyphsoff_T.png")), + m_IconGlyON_T(new QIcon(":/QmitkDiffusionImaging/glyphson_T.png")), + m_IconGlyOFF_C(new QIcon(":/QmitkDiffusionImaging/glyphsoff_C.png")), + m_IconGlyON_C(new QIcon(":/QmitkDiffusionImaging/glyphson_C.png")), + m_IconGlyOFF_S(new QIcon(":/QmitkDiffusionImaging/glyphsoff_S.png")), + m_IconGlyON_S(new QIcon(":/QmitkDiffusionImaging/glyphson_S.png")), + m_CurrentSelection(0), + m_CurrentPickingNode(0), + m_GlyIsOn_S(false), + m_GlyIsOn_C(false), + m_GlyIsOn_T(false), + m_FiberBundleObserverTag(0), + m_Color(NULL) { - currentThickSlicesMode = 1; - m_MyMenu = NULL; - int numThread = itk::MultiThreader::GetGlobalMaximumNumberOfThreads(); - if (numThread > 12) - numThread = 12; - itk::MultiThreader::SetGlobalDefaultNumberOfThreads(numThread); + currentThickSlicesMode = 1; + m_MyMenu = NULL; + int numThread = itk::MultiThreader::GetGlobalMaximumNumberOfThreads(); + if (numThread > 12) + numThread = 12; + itk::MultiThreader::SetGlobalDefaultNumberOfThreads(numThread); } QmitkControlVisualizationPropertiesView::QmitkControlVisualizationPropertiesView(const QmitkControlVisualizationPropertiesView& other) { - Q_UNUSED(other) + Q_UNUSED(other) throw std::runtime_error("Copy constructor not implemented"); } QmitkControlVisualizationPropertiesView::~QmitkControlVisualizationPropertiesView() { - if(m_SlicesRotationObserverTag1 ) - { - mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); - if( coordinator) - coordinator->RemoveObserver(m_SlicesRotationObserverTag1); - } - if( m_SlicesRotationObserverTag2) - { - mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); - if( coordinator ) - coordinator->RemoveObserver(m_SlicesRotationObserverTag1); - } - - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemovePostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); + if(m_SlicesRotationObserverTag1 ) + { + mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); + if( coordinator) + coordinator->RemoveObserver(m_SlicesRotationObserverTag1); + } + if( m_SlicesRotationObserverTag2) + { + mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); + if( coordinator ) + coordinator->RemoveObserver(m_SlicesRotationObserverTag1); + } + + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->RemovePostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); } void QmitkControlVisualizationPropertiesView::OnThickSlicesModeSelected( QAction* action ) { - currentThickSlicesMode = action->data().toInt(); - - switch(currentThickSlicesMode) - { - default: - case 1: - this->m_Controls->m_TSMenu->setText("MIP"); - break; - case 2: - this->m_Controls->m_TSMenu->setText("SUM"); - break; - case 3: - this->m_Controls->m_TSMenu->setText("WEIGH"); - break; - } - - mitk::DataNode* n; - n = this->m_MultiWidget->GetWidgetPlane1(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - n = this->m_MultiWidget->GetWidgetPlane2(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - n = this->m_MultiWidget->GetWidgetPlane3(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - - mitk::BaseRenderer::Pointer renderer = - this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer(); - if(renderer.IsNotNull()) - { - renderer->SendUpdateSlice(); - } - renderer = this->GetActiveStdMultiWidget()->GetRenderWindow2()->GetRenderer(); - if(renderer.IsNotNull()) - { - renderer->SendUpdateSlice(); - } - renderer = this->GetActiveStdMultiWidget()->GetRenderWindow3()->GetRenderer(); - if(renderer.IsNotNull()) - { - renderer->SendUpdateSlice(); - } - renderer->GetRenderingManager()->RequestUpdateAll(); -} + currentThickSlicesMode = action->data().toInt(); + + switch(currentThickSlicesMode) + { + default: + case 1: + this->m_Controls->m_TSMenu->setText("MIP"); + break; + case 2: + this->m_Controls->m_TSMenu->setText("SUM"); + break; + case 3: + this->m_Controls->m_TSMenu->setText("WEIGH"); + break; + } -void QmitkControlVisualizationPropertiesView::OnTSNumChanged(int num) -{ - if(num==0) - { - mitk::DataNode* n; - n = this->m_MultiWidget->GetWidgetPlane1(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); - n = this->m_MultiWidget->GetWidgetPlane2(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); - n = this->m_MultiWidget->GetWidgetPlane3(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); - } - else - { mitk::DataNode* n; n = this->m_MultiWidget->GetWidgetPlane1(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); n = this->m_MultiWidget->GetWidgetPlane2(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); n = this->m_MultiWidget->GetWidgetPlane3(); if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); - n = this->m_MultiWidget->GetWidgetPlane1(); if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); - n = this->m_MultiWidget->GetWidgetPlane2(); if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); - n = this->m_MultiWidget->GetWidgetPlane3(); if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); - } - - m_TSLabel->setText(QString::number(num*2+1)); - - mitk::BaseRenderer::Pointer renderer = - this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer(); - if(renderer.IsNotNull()) - { - renderer->SendUpdateSlice(); - } - renderer = this->GetActiveStdMultiWidget()->GetRenderWindow2()->GetRenderer(); - if(renderer.IsNotNull()) - { - renderer->SendUpdateSlice(); - } - renderer = this->GetActiveStdMultiWidget()->GetRenderWindow3()->GetRenderer(); - if(renderer.IsNotNull()) - { - renderer->SendUpdateSlice(); - } - renderer->GetRenderingManager()->RequestUpdateAll(mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS); + mitk::BaseRenderer::Pointer renderer = + this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer(); + if(renderer.IsNotNull()) + { + renderer->SendUpdateSlice(); + } + renderer = this->GetActiveStdMultiWidget()->GetRenderWindow2()->GetRenderer(); + if(renderer.IsNotNull()) + { + renderer->SendUpdateSlice(); + } + renderer = this->GetActiveStdMultiWidget()->GetRenderWindow3()->GetRenderer(); + if(renderer.IsNotNull()) + { + renderer->SendUpdateSlice(); + } + renderer->GetRenderingManager()->RequestUpdateAll(); +} + +void QmitkControlVisualizationPropertiesView::OnTSNumChanged(int num) +{ + if(num==0) + { + mitk::DataNode* n; + n = this->m_MultiWidget->GetWidgetPlane1(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( false ) ); + + n = this->m_MultiWidget->GetWidgetPlane2(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( false ) ); + + n = this->m_MultiWidget->GetWidgetPlane3(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( 0 ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( false ) ); + } + else + { + mitk::DataNode* n; + n = this->m_MultiWidget->GetWidgetPlane1(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( (num>0) ) ); + + n = this->m_MultiWidget->GetWidgetPlane2(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( (num>0) ) ); + + n = this->m_MultiWidget->GetWidgetPlane3(); + if(n) n->SetProperty( "reslice.thickslices", mitk::ResliceMethodProperty::New( currentThickSlicesMode ) ); + if(n) n->SetProperty( "reslice.thickslices.num", mitk::IntProperty::New( num ) ); + if(n) n->SetProperty( "reslice.thickslices.showarea", mitk::BoolProperty::New( (num>0) ) ); + } + + m_TSLabel->setText(QString::number(num*2+1)); + + mitk::BaseRenderer::Pointer renderer = this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer(); + if(renderer.IsNotNull()) + renderer->SendUpdateSlice(); + + renderer = this->GetActiveStdMultiWidget()->GetRenderWindow2()->GetRenderer(); + if(renderer.IsNotNull()) + renderer->SendUpdateSlice(); + + renderer = this->GetActiveStdMultiWidget()->GetRenderWindow3()->GetRenderer(); + if(renderer.IsNotNull()) + renderer->SendUpdateSlice(); + + renderer->GetRenderingManager()->RequestUpdateAll(mitk::RenderingManager::REQUEST_UPDATE_2DWINDOWS); } void QmitkControlVisualizationPropertiesView::CreateQtPartControl(QWidget *parent) { - if (!m_Controls) - { - // create GUI widgets - m_Controls = new Ui::QmitkControlVisualizationPropertiesViewControls; - m_Controls->setupUi(parent); - this->CreateConnections(); + if (!m_Controls) + { + // create GUI widgets + m_Controls = new Ui::QmitkControlVisualizationPropertiesViewControls; + m_Controls->setupUi(parent); + this->CreateConnections(); - // hide warning (ODFs in rotated planes) - m_Controls->m_lblRotatedPlanesWarning->hide(); + // hide warning (ODFs in rotated planes) + m_Controls->m_lblRotatedPlanesWarning->hide(); - m_MyMenu = new QMenu(parent); - connect( m_MyMenu, SIGNAL( aboutToShow() ), this, SLOT(OnMenuAboutToShow()) ); + m_MyMenu = new QMenu(parent); + connect( m_MyMenu, SIGNAL( aboutToShow() ), this, SLOT(OnMenuAboutToShow()) ); - // button for changing rotation mode - m_Controls->m_TSMenu->setMenu( m_MyMenu ); - //m_CrosshairModeButton->setIcon( QIcon( iconCrosshairMode_xpm ) ); + // button for changing rotation mode + m_Controls->m_TSMenu->setMenu( m_MyMenu ); + //m_CrosshairModeButton->setIcon( QIcon( iconCrosshairMode_xpm ) ); - m_Controls->params_frame->setVisible(false); + m_Controls->params_frame->setVisible(false); - QIcon icon5(":/QmitkDiffusionImaging/Refresh_48.png"); - m_Controls->m_Reinit->setIcon(icon5); - m_Controls->m_Focus->setIcon(icon5); + QIcon icon5(":/QmitkDiffusionImaging/Refresh_48.png"); + m_Controls->m_Reinit->setIcon(icon5); + m_Controls->m_Focus->setIcon(icon5); - QIcon iconColor(":/QmitkDiffusionImaging/color24.gif"); - m_Controls->m_PFColor->setIcon(iconColor); - m_Controls->m_Color->setIcon(iconColor); + QIcon iconColor(":/QmitkDiffusionImaging/color24.gif"); + m_Controls->m_PFColor->setIcon(iconColor); + m_Controls->m_Color->setIcon(iconColor); - QIcon iconReset(":/QmitkDiffusionImaging/reset.png"); - m_Controls->m_ResetColoring->setIcon(iconReset); + QIcon iconReset(":/QmitkDiffusionImaging/reset.png"); + m_Controls->m_ResetColoring->setIcon(iconReset); - m_Controls->m_PFColor->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + m_Controls->m_PFColor->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - QIcon iconCrosshair(":/QmitkDiffusionImaging/crosshair.png"); - m_Controls->m_Crosshair->setIcon(iconCrosshair); - // was is los - QIcon iconPaint(":/QmitkDiffusionImaging/paint2.png"); - m_Controls->m_TDI->setIcon(iconPaint); + QIcon iconCrosshair(":/QmitkDiffusionImaging/crosshair.png"); + m_Controls->m_Crosshair->setIcon(iconCrosshair); + // was is los + QIcon iconPaint(":/QmitkDiffusionImaging/paint2.png"); + m_Controls->m_TDI->setIcon(iconPaint); - QIcon iconFiberFade(":/QmitkDiffusionImaging/MapperEfx2D.png"); - m_Controls->m_FiberFading2D->setIcon(iconFiberFade); + QIcon iconFiberFade(":/QmitkDiffusionImaging/MapperEfx2D.png"); + m_Controls->m_FiberFading2D->setIcon(iconFiberFade); - m_Controls->m_TextureIntON->setCheckable(true); + m_Controls->m_TextureIntON->setCheckable(true); #ifndef DIFFUSION_IMAGING_EXTENDED - int size = m_Controls->m_AdditionalScaling->count(); - for(int t=0; tm_AdditionalScaling->itemText(t).toStdString() == "Scale by ASR") - { - m_Controls->m_AdditionalScaling->removeItem(t); - } - } + int size = m_Controls->m_AdditionalScaling->count(); + for(int t=0; tm_AdditionalScaling->itemText(t).toStdString() == "Scale by ASR") + { + m_Controls->m_AdditionalScaling->removeItem(t); + } + } #endif - m_Controls->m_OpacitySlider->setRange(0.0,1.0); - m_Controls->m_OpacitySlider->setLowerValue(0.0); - m_Controls->m_OpacitySlider->setUpperValue(0.0); - - m_Controls->m_ScalingFrame->setVisible(false); - m_Controls->m_NormalizationFrame->setVisible(false); - m_Controls->frame_tube->setVisible(false); - m_Controls->frame_wire->setVisible(false); - } - - m_IsInitialized = false; - m_SelListener = berry::ISelectionListener::Pointer(new CvpSelListener(this)); - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); - berry::ISelection::ConstPointer sel( - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - m_CurrentSelection = sel.Cast(); - m_SelListener.Cast()->DoSelectionChanged(sel); - m_IsInitialized = true; + m_Controls->m_OpacitySlider->setRange(0.0,1.0); + m_Controls->m_OpacitySlider->setLowerValue(0.0); + m_Controls->m_OpacitySlider->setUpperValue(0.0); + + m_Controls->m_ScalingFrame->setVisible(false); + m_Controls->m_NormalizationFrame->setVisible(false); + m_Controls->frame_tube->setVisible(false); + m_Controls->frame_wire->setVisible(false); + } + + m_IsInitialized = false; + m_SelListener = berry::ISelectionListener::Pointer(new CvpSelListener(this)); + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener(/*"org.mitk.views.datamanager",*/ m_SelListener); + berry::ISelection::ConstPointer sel( + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + m_CurrentSelection = sel.Cast(); + m_SelListener.Cast()->DoSelectionChanged(sel); + m_IsInitialized = true; } void QmitkControlVisualizationPropertiesView::OnMenuAboutToShow () { - // THICK SLICE SUPPORT - QMenu *myMenu = m_MyMenu; - myMenu->clear(); + // THICK SLICE SUPPORT + QMenu *myMenu = m_MyMenu; + myMenu->clear(); - QActionGroup* thickSlicesActionGroup = new QActionGroup(myMenu); - thickSlicesActionGroup->setExclusive(true); + QActionGroup* thickSlicesActionGroup = new QActionGroup(myMenu); + thickSlicesActionGroup->setExclusive(true); - mitk::BaseRenderer::Pointer renderer = - this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer(); + mitk::BaseRenderer::Pointer renderer = + this->GetActiveStdMultiWidget()->GetRenderWindow1()->GetRenderer(); - int currentTSMode = 0; - { - mitk::ResliceMethodProperty::Pointer m = dynamic_cast(renderer->GetCurrentWorldGeometry2DNode()->GetProperty( "reslice.thickslices" )); - if( m.IsNotNull() ) - currentTSMode = m->GetValueAsId(); - } + int currentTSMode = 0; + { + mitk::ResliceMethodProperty::Pointer m = dynamic_cast(renderer->GetCurrentWorldGeometry2DNode()->GetProperty( "reslice.thickslices" )); + if( m.IsNotNull() ) + currentTSMode = m->GetValueAsId(); + } + + int maxTS = 30; - const int maxTS = 30; + itk::VectorContainer::ConstPointer nodes = this->GetDataStorage()->GetAll(); + for (int i=0; iSize(); i++) + { + mitk::Image* image = dynamic_cast(nodes->ElementAt(i)->GetData()); + if (image) + { + int size = std::max(image->GetDimension(0), std::max(image->GetDimension(1), image->GetDimension(2))); + if (size>maxTS) + maxTS=size; + } + } + maxTS /= 2; - int currentNum = 0; - { - mitk::IntProperty::Pointer m = dynamic_cast(renderer->GetCurrentWorldGeometry2DNode()->GetProperty( "reslice.thickslices.num" )); - if( m.IsNotNull() ) + int currentNum = 0; { - currentNum = m->GetValue(); - if(currentNum < 0) currentNum = 0; - if(currentNum > maxTS) currentNum = maxTS; + mitk::IntProperty::Pointer m = dynamic_cast(renderer->GetCurrentWorldGeometry2DNode()->GetProperty( "reslice.thickslices.num" )); + if( m.IsNotNull() ) + { + currentNum = m->GetValue(); + if(currentNum < 0) currentNum = 0; + if(currentNum > maxTS) currentNum = maxTS; + } } - } - - if(currentTSMode==0) - currentNum=0; - - QSlider *m_TSSlider = new QSlider(myMenu); - m_TSSlider->setMinimum(0); - m_TSSlider->setMaximum(maxTS-1); - m_TSSlider->setValue(currentNum); - - m_TSSlider->setOrientation(Qt::Horizontal); - - connect( m_TSSlider, SIGNAL( valueChanged(int) ), this, SLOT( OnTSNumChanged(int) ) ); - - QHBoxLayout* _TSLayout = new QHBoxLayout; - _TSLayout->setContentsMargins(4,4,4,4); - _TSLayout->addWidget(m_TSSlider); - _TSLayout->addWidget(m_TSLabel=new QLabel(QString::number(currentNum*2+1),myMenu)); - - QWidget* _TSWidget = new QWidget; - _TSWidget->setLayout(_TSLayout); - - QActionGroup* thickSliceModeActionGroup = new QActionGroup(myMenu); - thickSliceModeActionGroup->setExclusive(true); - - QWidgetAction *m_TSSliderAction = new QWidgetAction(myMenu); - m_TSSliderAction->setDefaultWidget(_TSWidget); - myMenu->addAction(m_TSSliderAction); - - QAction* mipThickSlicesAction = new QAction(myMenu); - mipThickSlicesAction->setActionGroup(thickSliceModeActionGroup); - mipThickSlicesAction->setText("MIP (max. intensity proj.)"); - mipThickSlicesAction->setCheckable(true); - mipThickSlicesAction->setChecked(currentThickSlicesMode==1); - mipThickSlicesAction->setData(1); - myMenu->addAction( mipThickSlicesAction ); - - QAction* sumThickSlicesAction = new QAction(myMenu); - sumThickSlicesAction->setActionGroup(thickSliceModeActionGroup); - sumThickSlicesAction->setText("SUM (sum intensity proj.)"); - sumThickSlicesAction->setCheckable(true); - sumThickSlicesAction->setChecked(currentThickSlicesMode==2); - sumThickSlicesAction->setData(2); - myMenu->addAction( sumThickSlicesAction ); - - QAction* weightedThickSlicesAction = new QAction(myMenu); - weightedThickSlicesAction->setActionGroup(thickSliceModeActionGroup); - weightedThickSlicesAction->setText("WEIGHTED (gaussian proj.)"); - weightedThickSlicesAction->setCheckable(true); - weightedThickSlicesAction->setChecked(currentThickSlicesMode==3); - weightedThickSlicesAction->setData(3); - myMenu->addAction( weightedThickSlicesAction ); - - connect( thickSliceModeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(OnThickSlicesModeSelected(QAction*)) ); + + if(currentTSMode==0) + currentNum=0; + + QSlider *m_TSSlider = new QSlider(myMenu); + m_TSSlider->setMinimum(0); + m_TSSlider->setMaximum(maxTS-1); + m_TSSlider->setValue(currentNum); + + m_TSSlider->setOrientation(Qt::Horizontal); + + connect( m_TSSlider, SIGNAL( valueChanged(int) ), this, SLOT( OnTSNumChanged(int) ) ); + + QHBoxLayout* _TSLayout = new QHBoxLayout; + _TSLayout->setContentsMargins(4,4,4,4); + _TSLayout->addWidget(m_TSSlider); + _TSLayout->addWidget(m_TSLabel=new QLabel(QString::number(currentNum*2+1),myMenu)); + + QWidget* _TSWidget = new QWidget; + _TSWidget->setLayout(_TSLayout); + + QActionGroup* thickSliceModeActionGroup = new QActionGroup(myMenu); + thickSliceModeActionGroup->setExclusive(true); + + QWidgetAction *m_TSSliderAction = new QWidgetAction(myMenu); + m_TSSliderAction->setDefaultWidget(_TSWidget); + myMenu->addAction(m_TSSliderAction); + + QAction* mipThickSlicesAction = new QAction(myMenu); + mipThickSlicesAction->setActionGroup(thickSliceModeActionGroup); + mipThickSlicesAction->setText("MIP (max. intensity proj.)"); + mipThickSlicesAction->setCheckable(true); + mipThickSlicesAction->setChecked(currentThickSlicesMode==1); + mipThickSlicesAction->setData(1); + myMenu->addAction( mipThickSlicesAction ); + + QAction* sumThickSlicesAction = new QAction(myMenu); + sumThickSlicesAction->setActionGroup(thickSliceModeActionGroup); + sumThickSlicesAction->setText("SUM (sum intensity proj.)"); + sumThickSlicesAction->setCheckable(true); + sumThickSlicesAction->setChecked(currentThickSlicesMode==2); + sumThickSlicesAction->setData(2); + myMenu->addAction( sumThickSlicesAction ); + + QAction* weightedThickSlicesAction = new QAction(myMenu); + weightedThickSlicesAction->setActionGroup(thickSliceModeActionGroup); + weightedThickSlicesAction->setText("WEIGHTED (gaussian proj.)"); + weightedThickSlicesAction->setCheckable(true); + weightedThickSlicesAction->setChecked(currentThickSlicesMode==3); + weightedThickSlicesAction->setData(3); + myMenu->addAction( weightedThickSlicesAction ); + + connect( thickSliceModeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(OnThickSlicesModeSelected(QAction*)) ); } void QmitkControlVisualizationPropertiesView::StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget) { - m_MultiWidget = &stdMultiWidget; + m_MultiWidget = &stdMultiWidget; - if (m_MultiWidget) - { - mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); - if (coordinator) + if (m_MultiWidget) { - itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); - command2->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SliceRotation ); - m_SlicesRotationObserverTag1 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); - } + mitk::SlicesCoordinator* coordinator = m_MultiWidget->GetSlicesRotator(); + if (coordinator) + { + itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); + command2->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SliceRotation ); + m_SlicesRotationObserverTag1 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); + } - coordinator = m_MultiWidget->GetSlicesSwiveller(); - if (coordinator) - { - itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); - command2->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SliceRotation ); - m_SlicesRotationObserverTag2 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); + coordinator = m_MultiWidget->GetSlicesSwiveller(); + if (coordinator) + { + itk::ReceptorMemberCommand::Pointer command2 = itk::ReceptorMemberCommand::New(); + command2->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SliceRotation ); + m_SlicesRotationObserverTag2 = coordinator->AddObserver( mitk::SliceRotationEvent(), command2 ); + } } - } } void QmitkControlVisualizationPropertiesView::SliceRotation(const itk::EventObject&) { - // test if plane rotated - if( m_GlyIsOn_T || m_GlyIsOn_C || m_GlyIsOn_S ) - { - if( this->IsPlaneRotated() ) - { - // show label - m_Controls->m_lblRotatedPlanesWarning->show(); - } - else + // test if plane rotated + if( m_GlyIsOn_T || m_GlyIsOn_C || m_GlyIsOn_S ) { - //hide label - m_Controls->m_lblRotatedPlanesWarning->hide(); + if( this->IsPlaneRotated() ) + { + // show label + m_Controls->m_lblRotatedPlanesWarning->show(); + } + else + { + //hide label + m_Controls->m_lblRotatedPlanesWarning->hide(); + } } - } } void QmitkControlVisualizationPropertiesView::StdMultiWidgetNotAvailable() { - m_MultiWidget = NULL; + m_MultiWidget = NULL; } +void QmitkControlVisualizationPropertiesView::NodeRemoved(const mitk::DataNode* node) +{ + OnMenuAboutToShow(); +} + +#include void QmitkControlVisualizationPropertiesView::CreateConnections() { - if ( m_Controls ) - { - connect( (QObject*)(m_Controls->m_DisplayIndex), SIGNAL(valueChanged(int)), this, SLOT(DisplayIndexChanged(int)) ); - connect( (QObject*)(m_Controls->m_DisplayIndexSpinBox), SIGNAL(valueChanged(int)), this, SLOT(DisplayIndexChanged(int)) ); + if ( m_Controls ) + { + connect( (QObject*)(m_Controls->m_DisplayIndex), SIGNAL(valueChanged(int)), this, SLOT(DisplayIndexChanged(int)) ); + connect( (QObject*)(m_Controls->m_DisplayIndexSpinBox), SIGNAL(valueChanged(int)), this, SLOT(DisplayIndexChanged(int)) ); - connect( (QObject*)(m_Controls->m_TextureIntON), SIGNAL(clicked()), this, SLOT(TextIntON()) ); - connect( (QObject*)(m_Controls->m_Reinit), SIGNAL(clicked()), this, SLOT(Reinit()) ); + connect( (QObject*)(m_Controls->m_TextureIntON), SIGNAL(clicked()), this, SLOT(TextIntON()) ); + connect( (QObject*)(m_Controls->m_Reinit), SIGNAL(clicked()), this, SLOT(Reinit()) ); - connect( (QObject*)(m_Controls->m_VisibleOdfsON_T), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_T()) ); - connect( (QObject*)(m_Controls->m_VisibleOdfsON_S), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_S()) ); - connect( (QObject*)(m_Controls->m_VisibleOdfsON_C), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_C()) ); + connect( (QObject*)(m_Controls->m_VisibleOdfsON_T), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_T()) ); + connect( (QObject*)(m_Controls->m_VisibleOdfsON_S), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_S()) ); + connect( (QObject*)(m_Controls->m_VisibleOdfsON_C), SIGNAL(clicked()), this, SLOT(VisibleOdfsON_C()) ); - connect( (QObject*)(m_Controls->m_ShowMaxNumber), SIGNAL(editingFinished()), this, SLOT(ShowMaxNumberChanged()) ); - connect( (QObject*)(m_Controls->m_NormalizationDropdown), SIGNAL(currentIndexChanged(int)), this, SLOT(NormalizationDropdownChanged(int)) ); - connect( (QObject*)(m_Controls->m_ScalingFactor), SIGNAL(valueChanged(double)), this, SLOT(ScalingFactorChanged(double)) ); - connect( (QObject*)(m_Controls->m_AdditionalScaling), SIGNAL(currentIndexChanged(int)), this, SLOT(AdditionalScaling(int)) ); - connect( (QObject*)(m_Controls->m_IndexParam1), SIGNAL(valueChanged(double)), this, SLOT(IndexParam1Changed(double)) ); - connect( (QObject*)(m_Controls->m_IndexParam2), SIGNAL(valueChanged(double)), this, SLOT(IndexParam2Changed(double)) ); + connect( (QObject*)(m_Controls->m_ShowMaxNumber), SIGNAL(editingFinished()), this, SLOT(ShowMaxNumberChanged()) ); + connect( (QObject*)(m_Controls->m_NormalizationDropdown), SIGNAL(currentIndexChanged(int)), this, SLOT(NormalizationDropdownChanged(int)) ); + connect( (QObject*)(m_Controls->m_ScalingFactor), SIGNAL(valueChanged(double)), this, SLOT(ScalingFactorChanged(double)) ); + connect( (QObject*)(m_Controls->m_AdditionalScaling), SIGNAL(currentIndexChanged(int)), this, SLOT(AdditionalScaling(int)) ); + connect( (QObject*)(m_Controls->m_IndexParam1), SIGNAL(valueChanged(double)), this, SLOT(IndexParam1Changed(double)) ); + connect( (QObject*)(m_Controls->m_IndexParam2), SIGNAL(valueChanged(double)), this, SLOT(IndexParam2Changed(double)) ); - connect( (QObject*)(m_Controls->m_ScalingCheckbox), SIGNAL(clicked()), this, SLOT(ScalingCheckbox()) ); + connect( (QObject*)(m_Controls->m_ScalingCheckbox), SIGNAL(clicked()), this, SLOT(ScalingCheckbox()) ); - connect( (QObject*)(m_Controls->m_OpacitySlider), SIGNAL(spanChanged(double,double)), this, SLOT(OpacityChanged(double,double)) ); + connect( (QObject*)(m_Controls->m_OpacitySlider), SIGNAL(spanChanged(double,double)), this, SLOT(OpacityChanged(double,double)) ); - connect((QObject*) m_Controls->m_Wire, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationWire())); - connect((QObject*) m_Controls->m_Tube, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationTube())); - connect((QObject*) m_Controls->m_Color, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationColor())); - connect((QObject*) m_Controls->m_ResetColoring, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationResetColoring())); - connect((QObject*) m_Controls->m_Focus, SIGNAL(clicked()), (QObject*) this, SLOT(PlanarFigureFocus())); - connect((QObject*) m_Controls->m_FiberFading2D, SIGNAL(clicked()), (QObject*) this, SLOT( Fiber2DfadingEFX() ) ); - connect((QObject*) m_Controls->m_FiberThicknessSlider, SIGNAL(sliderReleased()), (QObject*) this, SLOT( FiberSlicingThickness2D() ) ); - connect((QObject*) m_Controls->m_FiberThicknessSlider, SIGNAL(valueChanged(int)), (QObject*) this, SLOT( FiberSlicingUpdateLabel(int) )); + connect((QObject*) m_Controls->m_Wire, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationWire())); + connect((QObject*) m_Controls->m_Tube, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationTube())); + connect((QObject*) m_Controls->m_Color, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationColor())); + connect((QObject*) m_Controls->m_ResetColoring, SIGNAL(clicked()), (QObject*) this, SLOT(BundleRepresentationResetColoring())); + connect((QObject*) m_Controls->m_Focus, SIGNAL(clicked()), (QObject*) this, SLOT(PlanarFigureFocus())); + connect((QObject*) m_Controls->m_FiberFading2D, SIGNAL(clicked()), (QObject*) this, SLOT( Fiber2DfadingEFX() ) ); + connect((QObject*) m_Controls->m_FiberThicknessSlider, SIGNAL(sliderReleased()), (QObject*) this, SLOT( FiberSlicingThickness2D() ) ); + connect((QObject*) m_Controls->m_FiberThicknessSlider, SIGNAL(valueChanged(int)), (QObject*) this, SLOT( FiberSlicingUpdateLabel(int) )); - connect((QObject*) m_Controls->m_Crosshair, SIGNAL(clicked()), (QObject*) this, SLOT(SetInteractor())); + connect((QObject*) m_Controls->m_Crosshair, SIGNAL(clicked()), (QObject*) this, SLOT(SetInteractor())); - connect((QObject*) m_Controls->m_PFWidth, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(PFWidth(int))); - connect((QObject*) m_Controls->m_PFColor, SIGNAL(clicked()), (QObject*) this, SLOT(PFColor())); + connect((QObject*) m_Controls->m_PFWidth, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(PFWidth(int))); + connect((QObject*) m_Controls->m_PFColor, SIGNAL(clicked()), (QObject*) this, SLOT(PFColor())); - connect((QObject*) m_Controls->m_TDI, SIGNAL(clicked()), (QObject*) this, SLOT(GenerateTdi())); + connect((QObject*) m_Controls->m_TDI, SIGNAL(clicked()), (QObject*) this, SLOT(GenerateTdi())); - connect((QObject*) m_Controls->m_LineWidth, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(LineWidthChanged(int))); - connect((QObject*) m_Controls->m_TubeRadius, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(TubeRadiusChanged(int))); - } + connect((QObject*) m_Controls->m_LineWidth, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(LineWidthChanged(int))); + connect((QObject*) m_Controls->m_TubeRadius, SIGNAL(valueChanged(int)), (QObject*) this, SLOT(TubeRadiusChanged(int))); + } } void QmitkControlVisualizationPropertiesView::Activated() { - berry::ISelection::ConstPointer sel( - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - m_CurrentSelection = sel.Cast(); - m_SelListener.Cast()->DoSelectionChanged(sel); - QmitkFunctionality::Activated(); + berry::ISelection::ConstPointer sel( + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + m_CurrentSelection = sel.Cast(); + m_SelListener.Cast()->DoSelectionChanged(sel); + QmitkFunctionality::Activated(); } void QmitkControlVisualizationPropertiesView::Deactivated() { - QmitkFunctionality::Deactivated(); + QmitkFunctionality::Deactivated(); } int QmitkControlVisualizationPropertiesView::GetSizeFlags(bool width) { - if(!width) - { - return berry::Constants::MIN | berry::Constants::MAX | berry::Constants::FILL; - } - else - { - return 0; - } + if(!width) + { + return berry::Constants::MIN | berry::Constants::MAX | berry::Constants::FILL; + } + else + { + return 0; + } } int QmitkControlVisualizationPropertiesView::ComputePreferredSize(bool width, int /*availableParallel*/, int /*availablePerpendicular*/, int preferredResult) { - if(width==false) - { - return m_FoundSingleOdfImage ? 120 : 80; - } - else - { - return preferredResult; - } + if(width==false) + { + return m_FoundSingleOdfImage ? 120 : 80; + } + else + { + return preferredResult; + } } // set diffusion image channel to b0 volume void QmitkControlVisualizationPropertiesView::NodeAdded(const mitk::DataNode *node) { - mitk::DataNode* notConst = const_cast(node); - if (dynamic_cast*>(notConst->GetData())) - { - mitk::DiffusionImage::Pointer dimg = dynamic_cast*>(notConst->GetData()); - - // if there is no b0 image in the dataset, the GetB0Indices() returns a vector of size 0 - // and hence we cannot set the Property directly to .front() - int displayChannelPropertyValue = 0; - mitk::DiffusionImage::BValueMap map = dimg->GetBValueMap(); - if( map[0].size() > 0) - displayChannelPropertyValue = map[0].front(); - - notConst->SetIntProperty("DisplayChannel", displayChannelPropertyValue ); - } + mitk::DataNode* notConst = const_cast(node); + if (dynamic_cast*>(notConst->GetData())) + { + mitk::DiffusionImage::Pointer dimg = dynamic_cast*>(notConst->GetData()); + + // if there is no b0 image in the dataset, the GetB0Indices() returns a vector of size 0 + // and hence we cannot set the Property directly to .front() + int displayChannelPropertyValue = 0; + mitk::DiffusionImage::BValueMap map = dimg->GetBValueMap(); + if( map[0].size() > 0) + displayChannelPropertyValue = map[0].front(); + + notConst->SetIntProperty("DisplayChannel", displayChannelPropertyValue ); + } + OnMenuAboutToShow(); } /* OnSelectionChanged is registered to SelectionService, therefore no need to implement SelectionService Listener explicitly */ void QmitkControlVisualizationPropertiesView::OnSelectionChanged( std::vector nodes ) { - // deactivate channel slider if no diffusion weighted image or tbss image is selected - m_Controls->m_DisplayIndex->setVisible(false); - m_Controls->m_DisplayIndexSpinBox->setVisible(false); - m_Controls->label_channel->setVisible(false); - - for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) - { - mitk::DataNode::Pointer node = *it; - - // check if node has data, - // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV - mitk::BaseData* nodeData = node->GetData(); - if(nodeData == NULL) - continue; + // deactivate channel slider if no diffusion weighted image or tbss image is selected + m_Controls->m_DisplayIndex->setVisible(false); + m_Controls->m_DisplayIndexSpinBox->setVisible(false); + m_Controls->label_channel->setVisible(false); - if (node.IsNotNull() && (dynamic_cast(nodeData) || - dynamic_cast*>(nodeData))) + for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) { - m_Controls->m_DisplayIndex->setVisible(true); - m_Controls->m_DisplayIndexSpinBox->setVisible(true); - m_Controls->label_channel->setVisible(true); - } - else if (node.IsNotNull() && dynamic_cast(node->GetData())) - { - if (m_Color.IsNotNull()) - m_Color->RemoveObserver(m_FiberBundleObserverTag); - - itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); - command->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SetFiberBundleCustomColor ); - m_Color = dynamic_cast(node->GetProperty("color", NULL)); - if (m_Color.IsNotNull()) - m_FiberBundleObserverTag = m_Color->AddObserver( itk::ModifiedEvent(), command ); - } - } + mitk::DataNode::Pointer node = *it; - for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) - { - mitk::DataNode::Pointer node = *it; + // check if node has data, + // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV + mitk::BaseData* nodeData = node->GetData(); + if(nodeData == NULL) + continue; - // check if node has data, - // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV - mitk::BaseData* nodeData = node->GetData(); - if(nodeData == NULL) - continue; + if (node.IsNotNull() && (dynamic_cast(nodeData) || + dynamic_cast*>(nodeData))) + { + m_Controls->m_DisplayIndex->setVisible(true); + m_Controls->m_DisplayIndexSpinBox->setVisible(true); + m_Controls->label_channel->setVisible(true); + } + else if (node.IsNotNull() && dynamic_cast(node->GetData())) + { + if (m_Color.IsNotNull()) + m_Color->RemoveObserver(m_FiberBundleObserverTag); + + itk::ReceptorMemberCommand::Pointer command = itk::ReceptorMemberCommand::New(); + command->SetCallbackFunction( this, &QmitkControlVisualizationPropertiesView::SetFiberBundleCustomColor ); + m_Color = dynamic_cast(node->GetProperty("color", NULL)); + if (m_Color.IsNotNull()) + m_FiberBundleObserverTag = m_Color->AddObserver( itk::ModifiedEvent(), command ); + } + } - if( node.IsNotNull() && (dynamic_cast(nodeData) || dynamic_cast(nodeData)) ) + for( std::vector::iterator it = nodes.begin(); it != nodes.end(); ++it ) { - if(m_NodeUsedForOdfVisualization.IsNotNull()) - { - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", false); - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", false); - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", false); - } - m_NodeUsedForOdfVisualization = node; - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", m_GlyIsOn_S); - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", m_GlyIsOn_C); - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", m_GlyIsOn_T); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + mitk::DataNode::Pointer node = *it; - m_Controls->m_TSMenu->setVisible(false); // deactivate mip etc. for tensor and q-ball images - break; + // check if node has data, + // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV + mitk::BaseData* nodeData = node->GetData(); + if(nodeData == NULL) + continue; + + if( node.IsNotNull() && (dynamic_cast(nodeData) || dynamic_cast(nodeData)) ) + { + if(m_NodeUsedForOdfVisualization.IsNotNull()) + { + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", false); + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", false); + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", false); + } + m_NodeUsedForOdfVisualization = node; + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", m_GlyIsOn_S); + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", m_GlyIsOn_C); + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", m_GlyIsOn_T); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); + + m_Controls->m_TSMenu->setVisible(false); // deactivate mip etc. for tensor and q-ball images + break; + } + else if( node.IsNotNull() && dynamic_cast(nodeData) ) + m_Controls->m_TSMenu->setVisible(false); + else + m_Controls->m_TSMenu->setVisible(true); } - else if( node.IsNotNull() && dynamic_cast(nodeData) ) - m_Controls->m_TSMenu->setVisible(false); - else - m_Controls->m_TSMenu->setVisible(true); - } - // if selection changes, set the current selction member and call SellListener::DoSelectionChanged - berry::ISelection::ConstPointer sel( - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - m_CurrentSelection = sel.Cast(); - m_SelListener.Cast()->DoSelectionChanged(sel); + // if selection changes, set the current selction member and call SellListener::DoSelectionChanged + berry::ISelection::ConstPointer sel( + this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); + m_CurrentSelection = sel.Cast(); + m_SelListener.Cast()->DoSelectionChanged(sel); } mitk::DataStorage::SetOfObjects::Pointer - QmitkControlVisualizationPropertiesView::ActiveSet(std::string classname) +QmitkControlVisualizationPropertiesView::ActiveSet(std::string classname) { - if (m_CurrentSelection) - { - mitk::DataStorage::SetOfObjects::Pointer set = - mitk::DataStorage::SetOfObjects::New(); - - int at = 0; - for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); - i != m_CurrentSelection->End(); - ++i) + if (m_CurrentSelection) { + mitk::DataStorage::SetOfObjects::Pointer set = + mitk::DataStorage::SetOfObjects::New(); - if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) - { - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + int at = 0; + for (IStructuredSelection::iterator i = m_CurrentSelection->Begin(); + i != m_CurrentSelection->End(); + ++i) + { - // check if node has data, - // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV - const mitk::BaseData* nodeData = node->GetData(); - if(nodeData == NULL) - continue; + if (mitk::DataNodeObject::Pointer nodeObj = i->Cast()) + { + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - if(QString(classname.c_str()).compare(nodeData->GetNameOfClass())==0) - { - set->InsertElement(at++, node); + // check if node has data, + // if some helper nodes are shown in the DataManager, the GetData() returns 0x0 which would lead to SIGSEV + const mitk::BaseData* nodeData = node->GetData(); + if(nodeData == NULL) + continue; + + if(QString(classname.c_str()).compare(nodeData->GetNameOfClass())==0) + { + set->InsertElement(at++, node); + } + } } - } - } - return set; - } + return set; + } - return 0; + return 0; } void QmitkControlVisualizationPropertiesView::SetBoolProp( - mitk::DataStorage::SetOfObjects::Pointer set, - std::string name, bool value) + mitk::DataStorage::SetOfObjects::Pointer set, + std::string name, bool value) { - if(set.IsNotNull()) - { - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) + if(set.IsNotNull()) { - (*itemiter)->SetBoolProperty(name.c_str(), value); - ++itemiter; + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetBoolProperty(name.c_str(), value); + ++itemiter; + } } - } } void QmitkControlVisualizationPropertiesView::SetIntProp( - mitk::DataStorage::SetOfObjects::Pointer set, - std::string name, int value) + mitk::DataStorage::SetOfObjects::Pointer set, + std::string name, int value) { - if(set.IsNotNull()) - { - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) + if(set.IsNotNull()) { - (*itemiter)->SetIntProperty(name.c_str(), value); - ++itemiter; + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetIntProperty(name.c_str(), value); + ++itemiter; + } } - } } void QmitkControlVisualizationPropertiesView::SetFloatProp( - mitk::DataStorage::SetOfObjects::Pointer set, - std::string name, float value) + mitk::DataStorage::SetOfObjects::Pointer set, + std::string name, float value) { - if(set.IsNotNull()) - { - - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) + if(set.IsNotNull()) { - (*itemiter)->SetFloatProperty(name.c_str(), value); - ++itemiter; + + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetFloatProperty(name.c_str(), value); + ++itemiter; + } } - } } void QmitkControlVisualizationPropertiesView::SetLevelWindowProp( - mitk::DataStorage::SetOfObjects::Pointer set, - std::string name, mitk::LevelWindow value) + mitk::DataStorage::SetOfObjects::Pointer set, + std::string name, mitk::LevelWindow value) { - if(set.IsNotNull()) - { + if(set.IsNotNull()) + { - mitk::LevelWindowProperty::Pointer prop = mitk::LevelWindowProperty::New(value); + mitk::LevelWindowProperty::Pointer prop = mitk::LevelWindowProperty::New(value); - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) - { - (*itemiter)->SetProperty(name.c_str(), prop); - ++itemiter; + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetProperty(name.c_str(), prop); + ++itemiter; + } } - } } void QmitkControlVisualizationPropertiesView::SetEnumProp( - mitk::DataStorage::SetOfObjects::Pointer set, - std::string name, mitk::EnumerationProperty::Pointer value) + mitk::DataStorage::SetOfObjects::Pointer set, + std::string name, mitk::EnumerationProperty::Pointer value) { - if(set.IsNotNull()) - { - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) + if(set.IsNotNull()) { - (*itemiter)->SetProperty(name.c_str(), value); - ++itemiter; + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetProperty(name.c_str(), value); + ++itemiter; + } } - } } void QmitkControlVisualizationPropertiesView::DisplayIndexChanged(int dispIndex) { - m_Controls->m_DisplayIndex->setValue(dispIndex); - m_Controls->m_DisplayIndexSpinBox->setValue(dispIndex); + m_Controls->m_DisplayIndex->setValue(dispIndex); + m_Controls->m_DisplayIndexSpinBox->setValue(dispIndex); - QString label = "Channel %1"; - label = label.arg(dispIndex); - m_Controls->label_channel->setText(label); + QString label = "Channel %1"; + label = label.arg(dispIndex); + m_Controls->label_channel->setText(label); - std::vector sets; - sets.push_back("DiffusionImage"); - sets.push_back("TbssImage"); + std::vector sets; + sets.push_back("DiffusionImage"); + sets.push_back("TbssImage"); - std::vector::iterator it = sets.begin(); - while(it != sets.end()) - { - std::string s = *it; - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet(s); - - if(set.IsNotNull()) + std::vector::iterator it = sets.begin(); + while(it != sets.end()) { + std::string s = *it; + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet(s); - mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); - mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); - while ( itemiter != itemiterend ) - { - (*itemiter)->SetIntProperty("DisplayChannel", dispIndex); - ++itemiter; - } + if(set.IsNotNull()) + { - //m_MultiWidget->RequestUpdate(); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - } + mitk::DataStorage::SetOfObjects::const_iterator itemiter( set->begin() ); + mitk::DataStorage::SetOfObjects::const_iterator itemiterend( set->end() ); + while ( itemiter != itemiterend ) + { + (*itemiter)->SetIntProperty("DisplayChannel", dispIndex); + ++itemiter; + } - it++; - } + //m_MultiWidget->RequestUpdate(); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } + + it++; + } } void QmitkControlVisualizationPropertiesView::Reinit() { - if (m_CurrentSelection) - { - mitk::DataNodeObject::Pointer nodeObj = - m_CurrentSelection->Begin()->Cast(); - mitk::DataNode::Pointer node = nodeObj->GetDataNode(); - mitk::BaseData::Pointer basedata = node->GetData(); - if (basedata.IsNotNull()) + if (m_CurrentSelection) { - mitk::RenderingManager::GetInstance()->InitializeViews( - basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + mitk::DataNodeObject::Pointer nodeObj = + m_CurrentSelection->Begin()->Cast(); + mitk::DataNode::Pointer node = nodeObj->GetDataNode(); + mitk::BaseData::Pointer basedata = node->GetData(); + if (basedata.IsNotNull()) + { + mitk::RenderingManager::GetInstance()->InitializeViews( + basedata->GetTimeGeometry(), mitk::RenderingManager::REQUEST_UPDATE_ALL, true ); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + } } - } } void QmitkControlVisualizationPropertiesView::TextIntON() { - if(m_TexIsOn) - { - m_Controls->m_TextureIntON->setIcon(*m_IconTexOFF); - } - else - { - m_Controls->m_TextureIntON->setIcon(*m_IconTexON); - } + if(m_TexIsOn) + { + m_Controls->m_TextureIntON->setIcon(*m_IconTexOFF); + } + else + { + m_Controls->m_TextureIntON->setIcon(*m_IconTexON); + } - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("DiffusionImage"); - SetBoolProp(set,"texture interpolation", !m_TexIsOn); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("DiffusionImage"); + SetBoolProp(set,"texture interpolation", !m_TexIsOn); - set = ActiveSet("TensorImage"); - SetBoolProp(set,"texture interpolation", !m_TexIsOn); + set = ActiveSet("TensorImage"); + SetBoolProp(set,"texture interpolation", !m_TexIsOn); - set = ActiveSet("QBallImage"); - SetBoolProp(set,"texture interpolation", !m_TexIsOn); + set = ActiveSet("QBallImage"); + SetBoolProp(set,"texture interpolation", !m_TexIsOn); - set = ActiveSet("Image"); - SetBoolProp(set,"texture interpolation", !m_TexIsOn); + set = ActiveSet("Image"); + SetBoolProp(set,"texture interpolation", !m_TexIsOn); - m_TexIsOn = !m_TexIsOn; + m_TexIsOn = !m_TexIsOn; - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::VisibleOdfsON_S() { - m_GlyIsOn_S = m_Controls->m_VisibleOdfsON_S->isChecked(); - if (m_NodeUsedForOdfVisualization.IsNull()) - { - MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; - return; - } - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", m_GlyIsOn_S); - VisibleOdfsON(0); + m_GlyIsOn_S = m_Controls->m_VisibleOdfsON_S->isChecked(); + if (m_NodeUsedForOdfVisualization.IsNull()) + { + MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; + return; + } + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_S", m_GlyIsOn_S); + VisibleOdfsON(0); } void QmitkControlVisualizationPropertiesView::VisibleOdfsON_T() { - m_GlyIsOn_T = m_Controls->m_VisibleOdfsON_T->isChecked(); - if (m_NodeUsedForOdfVisualization.IsNull()) - { - MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; - return; - } - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", m_GlyIsOn_T); - VisibleOdfsON(1); + m_GlyIsOn_T = m_Controls->m_VisibleOdfsON_T->isChecked(); + if (m_NodeUsedForOdfVisualization.IsNull()) + { + MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; + return; + } + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_T", m_GlyIsOn_T); + VisibleOdfsON(1); } void QmitkControlVisualizationPropertiesView::VisibleOdfsON_C() { - m_GlyIsOn_C = m_Controls->m_VisibleOdfsON_C->isChecked(); - if (m_NodeUsedForOdfVisualization.IsNull()) - { - MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; - return; - } - m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", m_GlyIsOn_C); - VisibleOdfsON(2); + m_GlyIsOn_C = m_Controls->m_VisibleOdfsON_C->isChecked(); + if (m_NodeUsedForOdfVisualization.IsNull()) + { + MITK_WARN << "ODF visualization activated but m_NodeUsedForOdfVisualization is NULL"; + return; + } + m_NodeUsedForOdfVisualization->SetBoolProperty("VisibleOdfs_C", m_GlyIsOn_C); + VisibleOdfsON(2); } bool QmitkControlVisualizationPropertiesView::IsPlaneRotated() { - // for all 2D renderwindows of m_MultiWidget check alignment - mitk::PlaneGeometry::ConstPointer displayPlane = dynamic_cast( m_MultiWidget->GetRenderWindow1()->GetRenderer()->GetCurrentWorldGeometry2D() ); - if (displayPlane.IsNull()) return false; + // for all 2D renderwindows of m_MultiWidget check alignment + mitk::PlaneGeometry::ConstPointer displayPlane = dynamic_cast( m_MultiWidget->GetRenderWindow1()->GetRenderer()->GetCurrentWorldGeometry2D() ); + if (displayPlane.IsNull()) return false; - mitk::Image* currentImage = dynamic_cast( m_NodeUsedForOdfVisualization->GetData() ); - if( currentImage == NULL ) - { - MITK_ERROR << " Casting problems. Returning false"; - return false; - } + mitk::Image* currentImage = dynamic_cast( m_NodeUsedForOdfVisualization->GetData() ); + if( currentImage == NULL ) + { + MITK_ERROR << " Casting problems. Returning false"; + return false; + } - int affectedDimension(-1); - int affectedSlice(-1); - return !(DetermineAffectedImageSlice( currentImage, displayPlane, affectedDimension, affectedSlice )); + int affectedDimension(-1); + int affectedSlice(-1); + return !(DetermineAffectedImageSlice( currentImage, displayPlane, affectedDimension, affectedSlice )); } void QmitkControlVisualizationPropertiesView::VisibleOdfsON(int view) { - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::ShowMaxNumberChanged() { - int maxNr = m_Controls->m_ShowMaxNumber->value(); - if ( maxNr < 1 ) - { - m_Controls->m_ShowMaxNumber->setValue( 1 ); - maxNr = 1; - } + int maxNr = m_Controls->m_ShowMaxNumber->value(); + if ( maxNr < 1 ) + { + m_Controls->m_ShowMaxNumber->setValue( 1 ); + maxNr = 1; + } - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetIntProp(set,"ShowMaxNumber", maxNr); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetIntProp(set,"ShowMaxNumber", maxNr); - set = ActiveSet("TensorImage"); - SetIntProp(set,"ShowMaxNumber", maxNr); + set = ActiveSet("TensorImage"); + SetIntProp(set,"ShowMaxNumber", maxNr); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::NormalizationDropdownChanged(int normDropdown) { - typedef mitk::OdfNormalizationMethodProperty PropType; - PropType::Pointer normMeth = PropType::New(); - - switch(normDropdown) - { - case 0: - normMeth->SetNormalizationToMinMax(); - break; - case 1: - normMeth->SetNormalizationToMax(); - break; - case 2: - normMeth->SetNormalizationToNone(); - break; - case 3: - normMeth->SetNormalizationToGlobalMax(); - break; - default: - normMeth->SetNormalizationToMinMax(); - } - - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetEnumProp(set,"Normalization", normMeth.GetPointer()); - - set = ActiveSet("TensorImage"); - SetEnumProp(set,"Normalization", normMeth.GetPointer()); - - // if(m_MultiWidget) - // m_MultiWidget->RequestUpdate(); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + typedef mitk::OdfNormalizationMethodProperty PropType; + PropType::Pointer normMeth = PropType::New(); + + switch(normDropdown) + { + case 0: + normMeth->SetNormalizationToMinMax(); + break; + case 1: + normMeth->SetNormalizationToMax(); + break; + case 2: + normMeth->SetNormalizationToNone(); + break; + case 3: + normMeth->SetNormalizationToGlobalMax(); + break; + default: + normMeth->SetNormalizationToMinMax(); + } + + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetEnumProp(set,"Normalization", normMeth.GetPointer()); + + set = ActiveSet("TensorImage"); + SetEnumProp(set,"Normalization", normMeth.GetPointer()); + + // if(m_MultiWidget) + // m_MultiWidget->RequestUpdate(); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkControlVisualizationPropertiesView::ScalingFactorChanged(double scalingFactor) { - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetFloatProp(set,"Scaling", scalingFactor); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetFloatProp(set,"Scaling", scalingFactor); - set = ActiveSet("TensorImage"); - SetFloatProp(set,"Scaling", scalingFactor); + set = ActiveSet("TensorImage"); + SetFloatProp(set,"Scaling", scalingFactor); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::AdditionalScaling(int additionalScaling) { - typedef mitk::OdfScaleByProperty PropType; - PropType::Pointer scaleBy = PropType::New(); - - switch(additionalScaling) - { - case 0: - scaleBy->SetScaleByNothing(); - break; - case 1: - scaleBy->SetScaleByGFA(); - //m_Controls->params_frame->setVisible(true); - break; + typedef mitk::OdfScaleByProperty PropType; + PropType::Pointer scaleBy = PropType::New(); + + switch(additionalScaling) + { + case 0: + scaleBy->SetScaleByNothing(); + break; + case 1: + scaleBy->SetScaleByGFA(); + //m_Controls->params_frame->setVisible(true); + break; #ifdef DIFFUSION_IMAGING_EXTENDED - case 2: - scaleBy->SetScaleByPrincipalCurvature(); - // commented in for SPIE paper, Principle curvature scaling - //m_Controls->params_frame->setVisible(true); - break; + case 2: + scaleBy->SetScaleByPrincipalCurvature(); + // commented in for SPIE paper, Principle curvature scaling + //m_Controls->params_frame->setVisible(true); + break; #endif - default: - scaleBy->SetScaleByNothing(); - } + default: + scaleBy->SetScaleByNothing(); + } - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetEnumProp(set,"ScaleBy", scaleBy.GetPointer()); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetEnumProp(set,"ScaleBy", scaleBy.GetPointer()); - set = ActiveSet("TensorImage"); - SetEnumProp(set,"ScaleBy", scaleBy.GetPointer()); + set = ActiveSet("TensorImage"); + SetEnumProp(set,"ScaleBy", scaleBy.GetPointer()); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::IndexParam1Changed(double param1) { - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetFloatProp(set,"IndexParam1", param1); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetFloatProp(set,"IndexParam1", param1); - set = ActiveSet("TensorImage"); - SetFloatProp(set,"IndexParam1", param1); + set = ActiveSet("TensorImage"); + SetFloatProp(set,"IndexParam1", param1); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::IndexParam2Changed(double param2) { - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetFloatProp(set,"IndexParam2", param2); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetFloatProp(set,"IndexParam2", param2); - set = ActiveSet("TensorImage"); - SetFloatProp(set,"IndexParam2", param2); + set = ActiveSet("TensorImage"); + SetFloatProp(set,"IndexParam2", param2); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::OpacityChanged(double l, double u) { - mitk::LevelWindow olw; - olw.SetRangeMinMax(l*255, u*255); + mitk::LevelWindow olw; + olw.SetRangeMinMax(l*255, u*255); - mitk::DataStorage::SetOfObjects::Pointer set = - ActiveSet("QBallImage"); - SetLevelWindowProp(set,"opaclevelwindow", olw); + mitk::DataStorage::SetOfObjects::Pointer set = + ActiveSet("QBallImage"); + SetLevelWindowProp(set,"opaclevelwindow", olw); - set = ActiveSet("TensorImage"); - SetLevelWindowProp(set,"opaclevelwindow", olw); + set = ActiveSet("TensorImage"); + SetLevelWindowProp(set,"opaclevelwindow", olw); - set = ActiveSet("Image"); - SetLevelWindowProp(set,"opaclevelwindow", olw); + set = ActiveSet("Image"); + SetLevelWindowProp(set,"opaclevelwindow", olw); - m_Controls->m_OpacityMinFaLabel->setText(QString::number(l,'f',2) + " : " + QString::number(u,'f',2)); + m_Controls->m_OpacityMinFaLabel->setText(QString::number(l,'f',2) + " : " + QString::number(u,'f',2)); - if(m_MultiWidget) - m_MultiWidget->RequestUpdate(); + if(m_MultiWidget) + m_MultiWidget->RequestUpdate(); } void QmitkControlVisualizationPropertiesView::ScalingCheckbox() { - m_Controls->m_ScalingFrame->setVisible( - m_Controls->m_ScalingCheckbox->isChecked()); - - if(!m_Controls->m_ScalingCheckbox->isChecked()) - { - m_Controls->m_AdditionalScaling->setCurrentIndex(0); - m_Controls->m_ScalingFactor->setValue(1.0); - } + m_Controls->m_ScalingFrame->setVisible( + m_Controls->m_ScalingCheckbox->isChecked()); + + if(!m_Controls->m_ScalingCheckbox->isChecked()) + { + m_Controls->m_AdditionalScaling->setCurrentIndex(0); + m_Controls->m_ScalingFactor->setValue(1.0); + } } void QmitkControlVisualizationPropertiesView::Fiber2DfadingEFX() { - if (m_SelectedNode) - { - bool currentMode; - m_SelectedNode->GetBoolProperty("Fiber2DfadeEFX", currentMode); - m_SelectedNode->SetProperty("Fiber2DfadeEFX", mitk::BoolProperty::New(!currentMode)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } + if (m_SelectedNode) + { + bool currentMode; + m_SelectedNode->GetBoolProperty("Fiber2DfadeEFX", currentMode); + m_SelectedNode->SetProperty("Fiber2DfadeEFX", mitk::BoolProperty::New(!currentMode)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::FiberSlicingThickness2D() { - if (m_SelectedNode) - { + if (m_SelectedNode) + { - float fibThickness = m_Controls->m_FiberThicknessSlider->value() * 0.1; - m_SelectedNode->SetProperty("Fiber2DSliceThickness", mitk::FloatProperty::New(fibThickness)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } + float fibThickness = m_Controls->m_FiberThicknessSlider->value() * 0.1; + m_SelectedNode->SetProperty("Fiber2DSliceThickness", mitk::FloatProperty::New(fibThickness)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::FiberSlicingUpdateLabel(int value) { - QString label = "Range %1 mm"; - label = label.arg(value * 0.1); - m_Controls->label_range->setText(label); - this->FiberSlicingThickness2D(); + QString label = "Range %1 mm"; + label = label.arg(value * 0.1); + m_Controls->label_range->setText(label); + this->FiberSlicingThickness2D(); } void QmitkControlVisualizationPropertiesView::BundleRepresentationWire() { - if(m_SelectedNode) - { - int width = m_Controls->m_LineWidth->value(); - m_SelectedNode->SetProperty("LineWidth",mitk::IntProperty::New(width)); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(15)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(18)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(1)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(2)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(3)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(4)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(0)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } + if(m_SelectedNode) + { + int width = m_Controls->m_LineWidth->value(); + m_SelectedNode->SetProperty("LineWidth",mitk::IntProperty::New(width)); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(15)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(18)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(1)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(2)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(3)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(4)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(0)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::BundleRepresentationTube() { - if(m_SelectedNode) - { - float radius = m_Controls->m_TubeRadius->value() / 100.0; - m_SelectedNode->SetProperty("TubeRadius",mitk::FloatProperty::New(radius)); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(17)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(13)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(16)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(0)); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } + if(m_SelectedNode) + { + float radius = m_Controls->m_TubeRadius->value() / 100.0; + m_SelectedNode->SetProperty("TubeRadius",mitk::FloatProperty::New(radius)); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(17)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(13)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(16)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + m_SelectedNode->SetProperty("ColorCoding",mitk::IntProperty::New(0)); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::SetFiberBundleCustomColor(const itk::EventObject& /*e*/) { - float color[3]; - m_SelectedNode->GetColor(color); - m_Controls->m_Color->setAutoFillBackground(true); - QString styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color[0]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[1]*255.0)); - styleSheet.append(","); - styleSheet.append(QString::number(color[2]*255.0)); - styleSheet.append(")"); - m_Controls->m_Color->setStyleSheet(styleSheet); - - m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(color[0], color[1], color[2])); - mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); - fib->SetColorCoding(mitk::FiberBundleX::COLORCODING_CUSTOM); - m_SelectedNode->Modified(); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); -} - -void QmitkControlVisualizationPropertiesView::BundleRepresentationColor() -{ - if(m_SelectedNode) - { - QColor color = QColorDialog::getColor(); - if (!color.isValid()) - return; - + float color[3]; + m_SelectedNode->GetColor(color); m_Controls->m_Color->setAutoFillBackground(true); QString styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color.red())); + styleSheet.append(QString::number(color[0]*255.0)); styleSheet.append(","); - styleSheet.append(QString::number(color.green())); + styleSheet.append(QString::number(color[1]*255.0)); styleSheet.append(","); - styleSheet.append(QString::number(color.blue())); + styleSheet.append(QString::number(color[2]*255.0)); styleSheet.append(")"); m_Controls->m_Color->setStyleSheet(styleSheet); - m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(color[0], color[1], color[2])); mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); fib->SetColorCoding(mitk::FiberBundleX::COLORCODING_CUSTOM); m_SelectedNode->Modified(); mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } } -void QmitkControlVisualizationPropertiesView::BundleRepresentationResetColoring() +void QmitkControlVisualizationPropertiesView::BundleRepresentationColor() { - if(m_SelectedNode) - { - MITK_INFO << "reset colorcoding to oBased"; - m_Controls->m_Color->setAutoFillBackground(true); - QString styleSheet = "background-color:rgb(255,255,255)"; - m_Controls->m_Color->setStyleSheet(styleSheet); - // m_SelectedNode->SetProperty("color",NULL); - m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(1.0, 1.0, 1.0)); + if(m_SelectedNode) + { + QColor color = QColorDialog::getColor(); + if (!color.isValid()) + return; + + m_Controls->m_Color->setAutoFillBackground(true); + QString styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color.red())); + styleSheet.append(","); + styleSheet.append(QString::number(color.green())); + styleSheet.append(","); + styleSheet.append(QString::number(color.blue())); + styleSheet.append(")"); + m_Controls->m_Color->setStyleSheet(styleSheet); + + m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); + fib->SetColorCoding(mitk::FiberBundleX::COLORCODING_CUSTOM); + m_SelectedNode->Modified(); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } +} - mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); - fib->SetColorCoding(mitk::FiberBundleX::COLORCODING_ORIENTATION_BASED); - fib->DoColorCodingOrientationBased(); - m_SelectedNode->Modified(); - mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); - } +void QmitkControlVisualizationPropertiesView::BundleRepresentationResetColoring() +{ + if(m_SelectedNode) + { + MITK_INFO << "reset colorcoding to oBased"; + m_Controls->m_Color->setAutoFillBackground(true); + QString styleSheet = "background-color:rgb(255,255,255)"; + m_Controls->m_Color->setStyleSheet(styleSheet); + // m_SelectedNode->SetProperty("color",NULL); + m_SelectedNode->SetProperty("color",mitk::ColorProperty::New(1.0, 1.0, 1.0)); + + mitk::FiberBundleX::Pointer fib = dynamic_cast(m_SelectedNode->GetData()); + fib->SetColorCoding(mitk::FiberBundleX::COLORCODING_ORIENTATION_BASED); + fib->DoColorCodingOrientationBased(); + m_SelectedNode->Modified(); + mitk::RenderingManager::GetInstance()->ForceImmediateUpdateAll(); + } } void QmitkControlVisualizationPropertiesView::PlanarFigureFocus() { - if(m_SelectedNode) - { - mitk::PlanarFigure* _PlanarFigure = 0; - _PlanarFigure = dynamic_cast (m_SelectedNode->GetData()); - - if (_PlanarFigure && _PlanarFigure->GetGeometry2D()) + if(m_SelectedNode) { + mitk::PlanarFigure* _PlanarFigure = 0; + _PlanarFigure = dynamic_cast (m_SelectedNode->GetData()); - QmitkRenderWindow* selectedRenderWindow = 0; - bool PlanarFigureInitializedWindow = false; - - QmitkRenderWindow* RenderWindow1 = - this->GetActiveStdMultiWidget()->GetRenderWindow1(); - - if (m_SelectedNode->GetBoolProperty("PlanarFigureInitializedWindow", - PlanarFigureInitializedWindow, RenderWindow1->GetRenderer())) - { - selectedRenderWindow = RenderWindow1; - } - - QmitkRenderWindow* RenderWindow2 = - this->GetActiveStdMultiWidget()->GetRenderWindow2(); - - if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow2->GetRenderer())) - { - selectedRenderWindow = RenderWindow2; - } - - QmitkRenderWindow* RenderWindow3 = - this->GetActiveStdMultiWidget()->GetRenderWindow3(); - - if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow3->GetRenderer())) - { - selectedRenderWindow = RenderWindow3; - } - - QmitkRenderWindow* RenderWindow4 = - this->GetActiveStdMultiWidget()->GetRenderWindow4(); - - if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( - "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, - RenderWindow4->GetRenderer())) - { - selectedRenderWindow = RenderWindow4; - } - - const mitk::PlaneGeometry - * _PlaneGeometry = - dynamic_cast (_PlanarFigure->GetGeometry2D()); - - mitk::VnlVector normal = _PlaneGeometry->GetNormalVnl(); - - mitk::Geometry2D::ConstPointer worldGeometry1 = - RenderWindow1->GetRenderer()->GetCurrentWorldGeometry2D(); - mitk::PlaneGeometry::ConstPointer _Plane1 = - dynamic_cast( worldGeometry1.GetPointer() ); - mitk::VnlVector normal1 = _Plane1->GetNormalVnl(); - - mitk::Geometry2D::ConstPointer worldGeometry2 = - RenderWindow2->GetRenderer()->GetCurrentWorldGeometry2D(); - mitk::PlaneGeometry::ConstPointer _Plane2 = - dynamic_cast( worldGeometry2.GetPointer() ); - mitk::VnlVector normal2 = _Plane2->GetNormalVnl(); - - mitk::Geometry2D::ConstPointer worldGeometry3 = - RenderWindow3->GetRenderer()->GetCurrentWorldGeometry2D(); - mitk::PlaneGeometry::ConstPointer _Plane3 = - dynamic_cast( worldGeometry3.GetPointer() ); - mitk::VnlVector normal3 = _Plane3->GetNormalVnl(); - - normal[0] = fabs(normal[0]); normal[1] = fabs(normal[1]); normal[2] = fabs(normal[2]); - normal1[0] = fabs(normal1[0]); normal1[1] = fabs(normal1[1]); normal1[2] = fabs(normal1[2]); - normal2[0] = fabs(normal2[0]); normal2[1] = fabs(normal2[1]); normal2[2] = fabs(normal2[2]); - normal3[0] = fabs(normal3[0]); normal3[1] = fabs(normal3[1]); normal3[2] = fabs(normal3[2]); - - double ang1 = angle(normal, normal1); - double ang2 = angle(normal, normal2); - double ang3 = angle(normal, normal3); - - if(ang1 < ang2 && ang1 < ang3) - { - selectedRenderWindow = RenderWindow1; - } - else - { - if(ang2 < ang3) + if (_PlanarFigure && _PlanarFigure->GetGeometry2D()) { - selectedRenderWindow = RenderWindow2; + + QmitkRenderWindow* selectedRenderWindow = 0; + bool PlanarFigureInitializedWindow = false; + + QmitkRenderWindow* RenderWindow1 = + this->GetActiveStdMultiWidget()->GetRenderWindow1(); + + if (m_SelectedNode->GetBoolProperty("PlanarFigureInitializedWindow", + PlanarFigureInitializedWindow, RenderWindow1->GetRenderer())) + { + selectedRenderWindow = RenderWindow1; + } + + QmitkRenderWindow* RenderWindow2 = + this->GetActiveStdMultiWidget()->GetRenderWindow2(); + + if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( + "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, + RenderWindow2->GetRenderer())) + { + selectedRenderWindow = RenderWindow2; + } + + QmitkRenderWindow* RenderWindow3 = + this->GetActiveStdMultiWidget()->GetRenderWindow3(); + + if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( + "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, + RenderWindow3->GetRenderer())) + { + selectedRenderWindow = RenderWindow3; + } + + QmitkRenderWindow* RenderWindow4 = + this->GetActiveStdMultiWidget()->GetRenderWindow4(); + + if (!selectedRenderWindow && m_SelectedNode->GetBoolProperty( + "PlanarFigureInitializedWindow", PlanarFigureInitializedWindow, + RenderWindow4->GetRenderer())) + { + selectedRenderWindow = RenderWindow4; + } + + const mitk::PlaneGeometry + * _PlaneGeometry = + dynamic_cast (_PlanarFigure->GetGeometry2D()); + + mitk::VnlVector normal = _PlaneGeometry->GetNormalVnl(); + + mitk::Geometry2D::ConstPointer worldGeometry1 = + RenderWindow1->GetRenderer()->GetCurrentWorldGeometry2D(); + mitk::PlaneGeometry::ConstPointer _Plane1 = + dynamic_cast( worldGeometry1.GetPointer() ); + mitk::VnlVector normal1 = _Plane1->GetNormalVnl(); + + mitk::Geometry2D::ConstPointer worldGeometry2 = + RenderWindow2->GetRenderer()->GetCurrentWorldGeometry2D(); + mitk::PlaneGeometry::ConstPointer _Plane2 = + dynamic_cast( worldGeometry2.GetPointer() ); + mitk::VnlVector normal2 = _Plane2->GetNormalVnl(); + + mitk::Geometry2D::ConstPointer worldGeometry3 = + RenderWindow3->GetRenderer()->GetCurrentWorldGeometry2D(); + mitk::PlaneGeometry::ConstPointer _Plane3 = + dynamic_cast( worldGeometry3.GetPointer() ); + mitk::VnlVector normal3 = _Plane3->GetNormalVnl(); + + normal[0] = fabs(normal[0]); normal[1] = fabs(normal[1]); normal[2] = fabs(normal[2]); + normal1[0] = fabs(normal1[0]); normal1[1] = fabs(normal1[1]); normal1[2] = fabs(normal1[2]); + normal2[0] = fabs(normal2[0]); normal2[1] = fabs(normal2[1]); normal2[2] = fabs(normal2[2]); + normal3[0] = fabs(normal3[0]); normal3[1] = fabs(normal3[1]); normal3[2] = fabs(normal3[2]); + + double ang1 = angle(normal, normal1); + double ang2 = angle(normal, normal2); + double ang3 = angle(normal, normal3); + + if(ang1 < ang2 && ang1 < ang3) + { + selectedRenderWindow = RenderWindow1; + } + else + { + if(ang2 < ang3) + { + selectedRenderWindow = RenderWindow2; + } + else + { + selectedRenderWindow = RenderWindow3; + } + } + + // make node visible + if (selectedRenderWindow) + { + const mitk::Point3D& centerP = _PlaneGeometry->GetOrigin(); + selectedRenderWindow->GetSliceNavigationController()->ReorientSlices( + centerP, _PlaneGeometry->GetNormal()); + } } - else + + // set interactor for new node (if not already set) + mitk::PlanarFigureInteractor::Pointer figureInteractor + = dynamic_cast(m_SelectedNode->GetDataInteractor().GetPointer()); + + if(figureInteractor.IsNull()) { - selectedRenderWindow = RenderWindow3; + figureInteractor = mitk::PlanarFigureInteractor::New(); + us::Module* planarFigureModule = us::ModuleRegistry::GetModule( "MitkPlanarFigure" ); + figureInteractor->LoadStateMachine("PlanarFigureInteraction.xml", planarFigureModule ); + figureInteractor->SetEventConfig( "PlanarFigureConfig.xml", planarFigureModule ); + figureInteractor->SetDataNode( m_SelectedNode ); } - } - - // make node visible - if (selectedRenderWindow) - { - const mitk::Point3D& centerP = _PlaneGeometry->GetOrigin(); - selectedRenderWindow->GetSliceNavigationController()->ReorientSlices( - centerP, _PlaneGeometry->GetNormal()); - } - } - - // set interactor for new node (if not already set) - mitk::PlanarFigureInteractor::Pointer figureInteractor - = dynamic_cast(m_SelectedNode->GetDataInteractor().GetPointer()); - if(figureInteractor.IsNull()) - { - figureInteractor = mitk::PlanarFigureInteractor::New(); - us::Module* planarFigureModule = us::ModuleRegistry::GetModule( "MitkPlanarFigure" ); - figureInteractor->LoadStateMachine("PlanarFigureInteraction.xml", planarFigureModule ); - figureInteractor->SetEventConfig( "PlanarFigureConfig.xml", planarFigureModule ); - figureInteractor->SetDataNode( m_SelectedNode ); + m_SelectedNode->SetProperty("planarfigure.iseditable",mitk::BoolProperty::New(true)); } - - m_SelectedNode->SetProperty("planarfigure.iseditable",mitk::BoolProperty::New(true)); - } } void QmitkControlVisualizationPropertiesView::SetInteractor() { - typedef std::vector Container; - Container _NodeSet = this->GetDataManagerSelection(); - mitk::DataNode* node = 0; - mitk::FiberBundleX* bundle = 0; - mitk::FiberBundleInteractor::Pointer bundleInteractor = 0; - - // finally add all nodes to the model - for(Container::const_iterator it=_NodeSet.begin(); it!=_NodeSet.end() - ; it++) - { - node = const_cast(*it); - bundle = dynamic_cast(node->GetData()); - - if(bundle) + typedef std::vector Container; + Container _NodeSet = this->GetDataManagerSelection(); + mitk::DataNode* node = 0; + mitk::FiberBundleX* bundle = 0; + mitk::FiberBundleInteractor::Pointer bundleInteractor = 0; + + // finally add all nodes to the model + for(Container::const_iterator it=_NodeSet.begin(); it!=_NodeSet.end() + ; it++) { - bundleInteractor = dynamic_cast(node->GetInteractor()); - - if(bundleInteractor.IsNotNull()) - mitk::GlobalInteraction::GetInstance()->RemoveInteractor(bundleInteractor); - - if(!m_Controls->m_Crosshair->isChecked()) - { - m_Controls->m_Crosshair->setChecked(false); - this->GetActiveStdMultiWidget()->GetRenderWindow4()->setCursor(Qt::ArrowCursor); - m_CurrentPickingNode = 0; - } - else - { - m_Controls->m_Crosshair->setChecked(true); - bundleInteractor = mitk::FiberBundleInteractor::New("FiberBundleInteractor", node); - mitk::GlobalInteraction::GetInstance()->AddInteractor(bundleInteractor); - this->GetActiveStdMultiWidget()->GetRenderWindow4()->setCursor(Qt::CrossCursor); - m_CurrentPickingNode = node; - } + node = const_cast(*it); + bundle = dynamic_cast(node->GetData()); + if(bundle) + { + bundleInteractor = dynamic_cast(node->GetInteractor()); + + if(bundleInteractor.IsNotNull()) + mitk::GlobalInteraction::GetInstance()->RemoveInteractor(bundleInteractor); + + if(!m_Controls->m_Crosshair->isChecked()) + { + m_Controls->m_Crosshair->setChecked(false); + this->GetActiveStdMultiWidget()->GetRenderWindow4()->setCursor(Qt::ArrowCursor); + m_CurrentPickingNode = 0; + } + else + { + m_Controls->m_Crosshair->setChecked(true); + bundleInteractor = mitk::FiberBundleInteractor::New("FiberBundleInteractor", node); + mitk::GlobalInteraction::GetInstance()->AddInteractor(bundleInteractor); + this->GetActiveStdMultiWidget()->GetRenderWindow4()->setCursor(Qt::CrossCursor); + m_CurrentPickingNode = node; + } + + } } - } } void QmitkControlVisualizationPropertiesView::PFWidth(int w) { - double width = w/10.0; - m_SelectedNode->SetProperty("planarfigure.line.width", mitk::FloatProperty::New(width) ); - m_SelectedNode->SetProperty("planarfigure.shadow.widthmodifier", mitk::FloatProperty::New(width) ); - m_SelectedNode->SetProperty("planarfigure.outline.width", mitk::FloatProperty::New(width) ); - m_SelectedNode->SetProperty("planarfigure.helperline.width", mitk::FloatProperty::New(width) ); + double width = w/10.0; + m_SelectedNode->SetProperty("planarfigure.line.width", mitk::FloatProperty::New(width) ); + m_SelectedNode->SetProperty("planarfigure.shadow.widthmodifier", mitk::FloatProperty::New(width) ); + m_SelectedNode->SetProperty("planarfigure.outline.width", mitk::FloatProperty::New(width) ); + m_SelectedNode->SetProperty("planarfigure.helperline.width", mitk::FloatProperty::New(width) ); - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); - QString label = "Width %1"; - label = label.arg(width); - m_Controls->label_pfwidth->setText(label); + QString label = "Width %1"; + label = label.arg(width); + m_Controls->label_pfwidth->setText(label); } void QmitkControlVisualizationPropertiesView::PFColor() { - QColor color = QColorDialog::getColor(); - if (!color.isValid()) - return; - - m_Controls->m_PFColor->setAutoFillBackground(true); - QString styleSheet = "background-color:rgb("; - styleSheet.append(QString::number(color.red())); - styleSheet.append(","); - styleSheet.append(QString::number(color.green())); - styleSheet.append(","); - styleSheet.append(QString::number(color.blue())); - styleSheet.append(")"); - m_Controls->m_PFColor->setStyleSheet(styleSheet); - - m_SelectedNode->SetProperty( "planarfigure.default.line.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - m_SelectedNode->SetProperty( "planarfigure.default.outline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - m_SelectedNode->SetProperty( "planarfigure.default.helperline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - m_SelectedNode->SetProperty( "planarfigure.default.markerline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - m_SelectedNode->SetProperty( "planarfigure.default.marker.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - - m_SelectedNode->SetProperty( "planarfigure.hover.line.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); - m_SelectedNode->SetProperty( "planarfigure.hover.outline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); - m_SelectedNode->SetProperty( "planarfigure.hover.helperline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); - m_SelectedNode->SetProperty( "color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); - - mitk::RenderingManager::GetInstance()->RequestUpdateAll(); + QColor color = QColorDialog::getColor(); + if (!color.isValid()) + return; + + m_Controls->m_PFColor->setAutoFillBackground(true); + QString styleSheet = "background-color:rgb("; + styleSheet.append(QString::number(color.red())); + styleSheet.append(","); + styleSheet.append(QString::number(color.green())); + styleSheet.append(","); + styleSheet.append(QString::number(color.blue())); + styleSheet.append(")"); + m_Controls->m_PFColor->setStyleSheet(styleSheet); + + m_SelectedNode->SetProperty( "planarfigure.default.line.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + m_SelectedNode->SetProperty( "planarfigure.default.outline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + m_SelectedNode->SetProperty( "planarfigure.default.helperline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + m_SelectedNode->SetProperty( "planarfigure.default.markerline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + m_SelectedNode->SetProperty( "planarfigure.default.marker.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + + m_SelectedNode->SetProperty( "planarfigure.hover.line.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); + m_SelectedNode->SetProperty( "planarfigure.hover.outline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); + m_SelectedNode->SetProperty( "planarfigure.hover.helperline.color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0) ); + m_SelectedNode->SetProperty( "color", mitk::ColorProperty::New(color.red()/255.0, color.green()/255.0, color.blue()/255.0)); + + mitk::RenderingManager::GetInstance()->RequestUpdateAll(); } void QmitkControlVisualizationPropertiesView::GenerateTdi() { - if(m_SelectedNode) - { - mitk::FiberBundleX* bundle = dynamic_cast(m_SelectedNode->GetData()); - if(!bundle) - return; - - typedef float OutPixType; - typedef itk::Image OutImageType; - - // run generator - itk::TractDensityImageFilter< OutImageType >::Pointer generator = itk::TractDensityImageFilter< OutImageType >::New(); - generator->SetFiberBundle(bundle); - generator->SetOutputAbsoluteValues(true); - generator->SetUpsamplingFactor(1); - generator->Update(); - - // get result - OutImageType::Pointer outImg = generator->GetOutput(); - - mitk::Image::Pointer img = mitk::Image::New(); - img->InitializeByItk(outImg.GetPointer()); - img->SetVolume(outImg->GetBufferPointer()); - - // to datastorage - mitk::DataNode::Pointer node = mitk::DataNode::New(); - node->SetData(img); - QString name(m_SelectedNode->GetName().c_str()); - name += "_TDI"; - node->SetName(name.toStdString()); - node->SetVisibility(true); - - GetDataStorage()->Add(node); - } + if(m_SelectedNode) + { + mitk::FiberBundleX* bundle = dynamic_cast(m_SelectedNode->GetData()); + if(!bundle) + return; + + typedef float OutPixType; + typedef itk::Image OutImageType; + + // run generator + itk::TractDensityImageFilter< OutImageType >::Pointer generator = itk::TractDensityImageFilter< OutImageType >::New(); + generator->SetFiberBundle(bundle); + generator->SetOutputAbsoluteValues(true); + generator->SetUpsamplingFactor(1); + generator->Update(); + + // get result + OutImageType::Pointer outImg = generator->GetOutput(); + + mitk::Image::Pointer img = mitk::Image::New(); + img->InitializeByItk(outImg.GetPointer()); + img->SetVolume(outImg->GetBufferPointer()); + + // to datastorage + mitk::DataNode::Pointer node = mitk::DataNode::New(); + node->SetData(img); + QString name(m_SelectedNode->GetName().c_str()); + name += "_TDI"; + node->SetName(name.toStdString()); + node->SetVisibility(true); + + GetDataStorage()->Add(node); + } } void QmitkControlVisualizationPropertiesView::LineWidthChanged(int w) { - QString label = "Width %1"; - label = label.arg(w); - m_Controls->label_linewidth->setText(label); - BundleRepresentationWire(); + QString label = "Width %1"; + label = label.arg(w); + m_Controls->label_linewidth->setText(label); + BundleRepresentationWire(); } void QmitkControlVisualizationPropertiesView::TubeRadiusChanged(int r) { - QString label = "Radius %1"; - label = label.arg(r / 100.0); - m_Controls->label_tuberadius->setText(label); - this->BundleRepresentationTube(); + QString label = "Radius %1"; + label = label.arg(r / 100.0); + m_Controls->label_tuberadius->setText(label); + this->BundleRepresentationTube(); } void QmitkControlVisualizationPropertiesView::Welcome() { - berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( - GetSite()->GetWorkbenchWindow(), false); + berry::PlatformUI::GetWorkbench()->GetIntroManager()->ShowIntro( + GetSite()->GetWorkbenchWindow(), false); } diff --git a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h index 3cae4d7730..3cafefbe18 100644 --- a/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h +++ b/Plugins/org.mitk.gui.qt.diffusionimaging/src/internal/QmitkControlVisualizationPropertiesView.h @@ -1,179 +1,181 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef _QMITKControlVisualizationPropertiesView_H_INCLUDED #define _QMITKControlVisualizationPropertiesView_H_INCLUDED #include #include #include "berryISelectionListener.h" #include "berryIStructuredSelection.h" #include "berryISizeProvider.h" #include "ui_QmitkControlVisualizationPropertiesViewControls.h" #include "mitkEnumerationProperty.h" /*! * \ingroup org_mitk_gui_qt_diffusionquantification_internal * * \brief QmitkControlVisualizationPropertiesView * * Document your class here. * * \sa QmitkFunctionality */ class QmitkControlVisualizationPropertiesView : public QmitkFunctionality//, public berry::ISizeProvider { friend struct CvpSelListener; // this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT public: static const std::string VIEW_ID; QmitkControlVisualizationPropertiesView(); QmitkControlVisualizationPropertiesView(const QmitkControlVisualizationPropertiesView& other); virtual ~QmitkControlVisualizationPropertiesView(); virtual void CreateQtPartControl(QWidget *parent); /// \brief Creation of the connections of main and control widget virtual void CreateConnections(); /// \brief Called when the functionality is activated virtual void Activated(); virtual void Deactivated(); virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget); virtual void StdMultiWidgetNotAvailable(); mitk::DataStorage::SetOfObjects::Pointer ActiveSet(std::string); void SetBoolProp (mitk::DataStorage::SetOfObjects::Pointer,std::string,bool); void SetIntProp (mitk::DataStorage::SetOfObjects::Pointer,std::string,int); void SetFloatProp(mitk::DataStorage::SetOfObjects::Pointer,std::string,float); void SetLevelWindowProp(mitk::DataStorage::SetOfObjects::Pointer,std::string,mitk::LevelWindow); void SetEnumProp (mitk::DataStorage::SetOfObjects::Pointer,std::string,mitk::EnumerationProperty::Pointer); virtual int GetSizeFlags(bool width); virtual int ComputePreferredSize(bool width, int availableParallel, int availablePerpendicular, int preferredResult); protected slots: void DisplayIndexChanged(int); void TextIntON(); void Reinit(); void VisibleOdfsON(int view); void VisibleOdfsON_S(); void VisibleOdfsON_T(); void VisibleOdfsON_C(); void ShowMaxNumberChanged(); void NormalizationDropdownChanged(int); void ScalingFactorChanged(double); void AdditionalScaling(int); void IndexParam1Changed(double); void IndexParam2Changed(double); void OpacityChanged(double,double); void ScalingCheckbox(); void OnThickSlicesModeSelected( QAction* action ); void OnTSNumChanged(int num); void OnMenuAboutToShow (); void BundleRepresentationWire(); void BundleRepresentationTube(); void BundleRepresentationColor(); void BundleRepresentationResetColoring(); void PlanarFigureFocus(); void Fiber2DfadingEFX(); void FiberSlicingThickness2D(); void FiberSlicingUpdateLabel(int); void SetInteractor(); void PFWidth(int); void PFColor(); void LineWidthChanged(int); void TubeRadiusChanged(int); void GenerateTdi(); void Welcome(); protected: + virtual void NodeRemoved(const mitk::DataNode* node); + /// \brief called by QmitkFunctionality when DataManager's selection has changed virtual void OnSelectionChanged( std::vector nodes ); virtual void NodeAdded(const mitk::DataNode *node); void SetFiberBundleCustomColor(const itk::EventObject& /*e*/); bool IsPlaneRotated(); void SliceRotation(const itk::EventObject&); Ui::QmitkControlVisualizationPropertiesViewControls* m_Controls; QmitkStdMultiWidget* m_MultiWidget; berry::ISelectionListener::Pointer m_SelListener; berry::IStructuredSelection::ConstPointer m_CurrentSelection; bool m_FoundSingleOdfImage; bool m_IsInitialized; mitk::DataNode::Pointer m_NodeUsedForOdfVisualization; QIcon* m_IconTexOFF; QIcon* m_IconTexON; QIcon* m_IconGlyOFF_T; QIcon* m_IconGlyON_T; QIcon* m_IconGlyOFF_C; QIcon* m_IconGlyON_C; QIcon* m_IconGlyOFF_S; QIcon* m_IconGlyON_S; bool m_TexIsOn; bool m_GlyIsOn_T; bool m_GlyIsOn_C; bool m_GlyIsOn_S; int currentThickSlicesMode; QLabel* m_TSLabel; QMenu* m_MyMenu; // for planarfigure and bundle handling: mitk::DataNode* m_SelectedNode; mitk::DataNode* m_CurrentPickingNode; unsigned long m_SlicesRotationObserverTag1; unsigned long m_SlicesRotationObserverTag2; unsigned long m_FiberBundleObserverTag; mitk::ColorProperty::Pointer m_Color; }; #endif // _QMITKControlVisualizationPropertiesView_H_INCLUDED