Skip to content
Snippets Groups Projects
Commit 167f78b2 authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #6211. PV Plugins use Integrated Radius and show Spheres.

parent ef50e80b
No related branches found
No related tags found
No related merge requests found
...@@ -10,10 +10,13 @@ ...@@ -10,10 +10,13 @@
<SimpleStringInformationHelper /> <SimpleStringInformationHelper />
</StringVectorProperty> </StringVectorProperty>
<DoubleVectorProperty <DoubleVectorProperty
name="Peak Width" name="Peak Radius"
command="SetWidth" command="SetRadius"
number_of_elements="1" number_of_elements="1"
default_values="0.05"> default_values="0.05">
<Documentation>
Set the Radius of the Peak Marker. This is automatically determined if peaks in the PeaksWorkspace has been integrated.
</Documentation>
</DoubleVectorProperty> </DoubleVectorProperty>
<StringVectorProperty <StringVectorProperty
name="FileName" name="FileName"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "vtkPointData.h" #include "vtkPointData.h"
#include "vtkTransform.h" #include "vtkTransform.h"
#include "vtkStreamingDemandDrivenPipeline.h" #include "vtkStreamingDemandDrivenPipeline.h"
#include <vtkCubeSource.h> #include <vtkSphereSource.h>
#include "MantidVatesAPI/FilteringUpdateProgressAction.h" #include "MantidVatesAPI/FilteringUpdateProgressAction.h"
#include "MantidVatesAPI/vtkPeakMarkerFactory.h" #include "MantidVatesAPI/vtkPeakMarkerFactory.h"
...@@ -41,9 +41,9 @@ vtkPeaksReader::~vtkPeaksReader() ...@@ -41,9 +41,9 @@ vtkPeaksReader::~vtkPeaksReader()
} }
void vtkPeaksReader::SetWidth(double width) void vtkPeaksReader::SetRadius(double radius)
{ {
m_width = width; m_radius = radius;
this->Modified(); this->Modified();
} }
...@@ -78,18 +78,24 @@ int vtkPeaksReader::RequestData(vtkInformation * vtkNotUsed(request), vtkInforma ...@@ -78,18 +78,24 @@ int vtkPeaksReader::RequestData(vtkInformation * vtkNotUsed(request), vtkInforma
FilterUpdateProgressAction<vtkPeaksReader> drawingProgressUpdate(this, "Drawing..."); FilterUpdateProgressAction<vtkPeaksReader> drawingProgressUpdate(this, "Drawing...");
vtkDataSet * structuredMesh = p_peakFactory->create(drawingProgressUpdate); vtkDataSet * structuredMesh = p_peakFactory->create(drawingProgressUpdate);
vtkCubeSource* cube = vtkCubeSource::New(); // Pick the radius up from the factory if possible, otherwise use the user-provided value.
cube->SetXLength(m_width); double peakRadius = m_radius;
cube->SetYLength(m_width); if(p_peakFactory->isPeaksWorkspaceIntegrated())
cube->SetZLength(m_width); {
peakRadius = p_peakFactory->getIntegrationRadius();
}
vtkPVGlyphFilter* glyphFilter = vtkPVGlyphFilter::New(); vtkSphereSource *sphere = vtkSphereSource::New();
sphere->SetRadius(peakRadius);
vtkPVGlyphFilter *glyphFilter = vtkPVGlyphFilter::New();
glyphFilter->SetInput(structuredMesh); glyphFilter->SetInput(structuredMesh);
glyphFilter->SetSource(cube->GetOutput()); glyphFilter->SetSource(sphere->GetOutput());
glyphFilter->Update(); glyphFilter->Update();
vtkPolyData* glyphed = glyphFilter->GetOutput(); vtkPolyData *glyphed = glyphFilter->GetOutput();
output->ShallowCopy(glyphed); output->ShallowCopy(glyphed);
glyphFilter->Delete(); glyphFilter->Delete();
return 1; return 1;
......
...@@ -13,7 +13,7 @@ public: ...@@ -13,7 +13,7 @@ public:
vtkSetStringMacro(FileName); vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName); vtkGetStringMacro(FileName);
int CanReadFile(const char* fname); int CanReadFile(const char* fname);
void SetWidth(double width); void SetRadius(double width);
void SetDimensions(int dimensions); void SetDimensions(int dimensions);
/// Called by presenter to force progress information updating. /// Called by presenter to force progress information updating.
void updateAlgorithmProgress(double progress, const std::string& message); void updateAlgorithmProgress(double progress, const std::string& message);
...@@ -35,7 +35,7 @@ private: ...@@ -35,7 +35,7 @@ private:
void operator = (const vtkPeaksReader&); void operator = (const vtkPeaksReader&);
//Peak width; //Peak width;
double m_width; double m_radius;
/// File name from which to read. /// File name from which to read.
char *FileName; char *FileName;
......
...@@ -16,11 +16,14 @@ ...@@ -16,11 +16,14 @@
information_only="0"> information_only="0">
</StringVectorProperty> </StringVectorProperty>
<DoubleVectorProperty <DoubleVectorProperty
name="Peak Width" name="Peak Radius"
command="SetWidth" command="SetRadius"
number_of_elements="1" number_of_elements="1"
default_values="0.05" default_values="0.05"
information_only="0"> information_only="0">
<Documentation>
Set the Radius of the Peak Marker. This is automatically determined if peaks in the PeaksWorkspace has been integrated.
</Documentation>
</DoubleVectorProperty> </DoubleVectorProperty>
</SourceProxy> </SourceProxy>
</ProxyGroup> </ProxyGroup>
......
#include "vtkPeaksSource.h" #include "vtkPeaksSource.h"
#include "vtkCubeSource.h" #include "vtkSphereSource.h"
#include "vtkInformation.h" #include "vtkInformation.h"
#include "vtkInformationVector.h" #include "vtkInformationVector.h"
#include "vtkObjectFactory.h" #include "vtkObjectFactory.h"
...@@ -46,9 +46,9 @@ void vtkPeaksSource::SetWsName(std::string name) ...@@ -46,9 +46,9 @@ void vtkPeaksSource::SetWsName(std::string name)
} }
} }
void vtkPeaksSource::SetWidth(double width) void vtkPeaksSource::SetRadius(double radius)
{ {
m_width = width; m_radius = radius;
this->Modified(); this->Modified();
} }
...@@ -60,7 +60,6 @@ int vtkPeaksSource::RequestData(vtkInformation *, vtkInformationVector **, ...@@ -60,7 +60,6 @@ int vtkPeaksSource::RequestData(vtkInformation *, vtkInformationVector **,
{ {
vtkInformation *outInfo = outputVector->GetInformationObject(0); vtkInformation *outInfo = outputVector->GetInformationObject(0);
//FilterUpdateProgressAction<vtkPeaksSource> loadingProgressUpdate(this, "Loading...");
FilterUpdateProgressAction<vtkPeaksSource> drawingProgressUpdate(this, "Drawing..."); FilterUpdateProgressAction<vtkPeaksSource> drawingProgressUpdate(this, "Drawing...");
vtkPolyData *output = vtkPolyData::SafeDownCast( vtkPolyData *output = vtkPolyData::SafeDownCast(
...@@ -72,14 +71,19 @@ int vtkPeaksSource::RequestData(vtkInformation *, vtkInformationVector **, ...@@ -72,14 +71,19 @@ int vtkPeaksSource::RequestData(vtkInformation *, vtkInformationVector **,
p_peakFactory->initialize(m_PeakWS); p_peakFactory->initialize(m_PeakWS);
vtkDataSet *structuredMesh = p_peakFactory->create(drawingProgressUpdate); vtkDataSet *structuredMesh = p_peakFactory->create(drawingProgressUpdate);
vtkCubeSource *cube = vtkCubeSource::New(); // Pick the radius up from the factory if possible, otherwise use the user-provided value.
cube->SetXLength(m_width); double peakRadius = m_radius;
cube->SetYLength(m_width); if(p_peakFactory->isPeaksWorkspaceIntegrated())
cube->SetZLength(m_width); {
peakRadius = p_peakFactory->getIntegrationRadius();
}
vtkSphereSource *sphere = vtkSphereSource::New();
sphere->SetRadius(peakRadius);
vtkPVGlyphFilter *glyphFilter = vtkPVGlyphFilter::New(); vtkPVGlyphFilter *glyphFilter = vtkPVGlyphFilter::New();
glyphFilter->SetInput(structuredMesh); glyphFilter->SetInput(structuredMesh);
glyphFilter->SetSource(cube->GetOutput()); glyphFilter->SetSource(sphere->GetOutput());
glyphFilter->Update(); glyphFilter->Update();
vtkPolyData *glyphed = glyphFilter->GetOutput(); vtkPolyData *glyphed = glyphFilter->GetOutput();
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
vtkTypeRevisionMacro(vtkPeaksSource,vtkPolyDataAlgorithm); vtkTypeRevisionMacro(vtkPeaksSource,vtkPolyDataAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent); void PrintSelf(ostream& os, vtkIndent indent);
void SetWidth(double width); void SetRadius(double radius);
void SetWsName(std::string wsName); void SetWsName(std::string wsName);
/// Update the algorithm progress. /// Update the algorithm progress.
void updateAlgorithmProgress(double progress, const std::string& message); void updateAlgorithmProgress(double progress, const std::string& message);
...@@ -59,7 +59,7 @@ private: ...@@ -59,7 +59,7 @@ private:
std::string m_wsName; std::string m_wsName;
/// Width of the glyphs /// Width of the glyphs
double m_width; double m_radius;
/// Cache for the workspace type name /// Cache for the workspace type name
std::string m_wsTypeName; std::string m_wsTypeName;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment