-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #4240. Adding skeleton for source plugin.
Making the new source plugin from a copy of the vtkMDEWSource class. This means the new plugin doesn't do the right thing, but will compile.
- Loading branch information
Michael Reuter
committed
Dec 1, 2011
1 parent
f8b0ae1
commit bbb335d
Showing
5 changed files
with
366 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
add_subdirectory( MDEWSource ) | ||
add_subdirectory( MDHWSource ) | ||
add_subdirectory( PeaksSource ) |
16 changes: 16 additions & 0 deletions
16
Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDHWSource/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
PROJECT(MantidParaViewMDHWSource) | ||
|
||
ADD_PARAVIEW_PLUGIN(MantidParaViewMDHWSourceSMPlugin "1.0" | ||
SERVER_MANAGER_XML MDHWSource.xml | ||
SERVER_MANAGER_SOURCES vtkMDHWSource.cxx) | ||
|
||
# Add to the 'VatesParaViewPlugins' group in VS | ||
set_property( TARGET MantidParaViewMDHWSourceSMPlugin PROPERTY FOLDER "MantidVatesParaViewPlugins" ) | ||
|
||
target_link_libraries( MantidParaViewMDHWSourceSMPlugin | ||
${MANTID_SUBPROJECT_LIBS} ) | ||
|
||
# Put library into subfolder. | ||
SET_TARGET_OUTPUT_DIRECTORY(MantidParaViewMDHWSourceSMPlugin ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${PVPLUGINS_DIR}) | ||
|
||
install( TARGETS MantidParaViewMDHWSourceSMPlugin ${TARGET_TYPE} DESTINATION ${PVPLUGINS_DIR} ) |
42 changes: 42 additions & 0 deletions
42
Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDHWSource/MDHWSource.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<ServerManagerConfiguration> | ||
<!-- Begin MDEWSource --> | ||
<ProxyGroup name="sources"> | ||
<SourceProxy name="MDHW Source" class="vtkMDHWSource"> | ||
<StringVectorProperty | ||
name="WorkspaceTypeName" | ||
command="GetWorkspaceTypeName" | ||
number_of_elements="1" | ||
information_only="1"> | ||
<SimpleStringInformationHelper /> | ||
</StringVectorProperty> | ||
<IntVectorProperty | ||
name="Recursion Depth" | ||
command="SetDepth" | ||
number_of_elements="1" | ||
default_values="1000"> | ||
</IntVectorProperty> | ||
<StringVectorProperty | ||
name="Mantid Workspace Name" | ||
command="SetWsName" | ||
number_of_elements="1" | ||
information_only="0"> | ||
</StringVectorProperty> | ||
<StringVectorProperty | ||
name="InputGeometryXML" | ||
command="GetInputGeometryXML" | ||
number_of_elements="1" | ||
information_only="1"> | ||
<SimpleStringInformationHelper /> | ||
</StringVectorProperty> | ||
<DoubleVectorProperty | ||
name="TimestepValues" | ||
information_only="1"> | ||
<TimeStepsInformationHelper/> | ||
<Documentation> | ||
Available timestep values. | ||
</Documentation> | ||
</DoubleVectorProperty> | ||
</SourceProxy> | ||
</ProxyGroup> | ||
<!-- End MDHWSource --> | ||
</ServerManagerConfiguration> |
218 changes: 218 additions & 0 deletions
218
Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDHWSource/vtkMDHWSource.cxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
#include "vtkBox.h" | ||
#include "vtkMDHWSource.h" | ||
#include "vtkInformation.h" | ||
#include "vtkInformationVector.h" | ||
#include "vtkObjectFactory.h" | ||
#include "vtkPVClipDataSet.h" | ||
#include "vtkUnstructuredGridAlgorithm.h" | ||
#include "vtkUnstructuredGrid.h" | ||
#include "vtkStreamingDemandDrivenPipeline.h" | ||
|
||
#include "MantidVatesAPI/MDEWInMemoryLoadingPresenter.h" | ||
#include "MantidVatesAPI/MDLoadingViewAdapter.h" | ||
#include "MantidVatesAPI/ADSWorkspaceProvider.h" | ||
#include "MantidVatesAPI/vtkMDEWHexahedronFactory.h" | ||
#include "MantidVatesAPI/FilteringUpdateProgressAction.h" | ||
#include "MantidVatesAPI/IgnoreZerosThresholdRange.h" | ||
|
||
using namespace Mantid::VATES; | ||
|
||
vtkCxxRevisionMacro(vtkMDHWSource, "$Revision: 1.0 $"); | ||
vtkStandardNewMacro(vtkMDHWSource); | ||
|
||
/// Constructor | ||
vtkMDHWSource::vtkMDHWSource() : m_wsName(""), m_depth(1000), m_time(0), m_presenter(NULL) | ||
{ | ||
this->SetNumberOfInputPorts(0); | ||
this->SetNumberOfOutputPorts(1); | ||
} | ||
|
||
/// Destructor | ||
vtkMDHWSource::~vtkMDHWSource() | ||
{ | ||
delete m_presenter; | ||
} | ||
|
||
/* | ||
Setter for the recursion depth | ||
@param depth : recursion depth to use | ||
*/ | ||
void vtkMDHWSource::SetDepth(int depth) | ||
{ | ||
size_t temp = depth; | ||
if(m_depth != temp) | ||
{ | ||
this->m_depth = temp; | ||
this->Modified(); | ||
} | ||
} | ||
|
||
/* | ||
Setter for the workspace name. | ||
@param name : workspace name to extract from ADS. | ||
*/ | ||
void vtkMDHWSource::SetWsName(std::string name) | ||
{ | ||
if(m_wsName != name) | ||
{ | ||
m_wsName = name; | ||
this->Modified(); | ||
} | ||
} | ||
|
||
/** | ||
Gets the geometry xml from the workspace. Allows object panels to configure themeselves. | ||
@return geometry xml const * char reference. | ||
*/ | ||
const char* vtkMDHWSource::GetInputGeometryXML() | ||
{ | ||
if(m_presenter == NULL) | ||
{ | ||
return ""; | ||
} | ||
try | ||
{ | ||
return m_presenter->getGeometryXML().c_str(); | ||
} | ||
catch(std::runtime_error&) | ||
{ | ||
return ""; | ||
} | ||
} | ||
|
||
|
||
int vtkMDHWSource::RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *outputVector) | ||
{ | ||
if(m_presenter->canReadFile()) | ||
{ | ||
using namespace Mantid::VATES; | ||
//get the info objects | ||
vtkInformation *outInfo = outputVector->GetInformationObject(0); | ||
|
||
|
||
if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())) | ||
{ | ||
// usually only one actual step requested | ||
m_time =outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS())[0]; | ||
} | ||
|
||
FilterUpdateProgressAction<vtkMDHWSource> updateHandler(this); | ||
vtkMDEWHexahedronFactory* hexahedronFactory = new vtkMDEWHexahedronFactory(ThresholdRange_scptr(new IgnoreZerosThresholdRange()), "signal"); | ||
hexahedronFactory->setTime(m_time); | ||
vtkDataSet* product = m_presenter->execute(hexahedronFactory, updateHandler); | ||
|
||
//-------------------------------------------------------- Corrects problem whereby boundaries not set propertly in PV. | ||
vtkBox* box = vtkBox::New(); | ||
box->SetBounds(product->GetBounds()); | ||
vtkPVClipDataSet* clipper = vtkPVClipDataSet::New(); | ||
clipper->SetInput(product); | ||
clipper->SetClipFunction(box); | ||
clipper->SetInsideOut(true); | ||
clipper->Update(); | ||
vtkDataSet* clipperOutput = clipper->GetOutput(); | ||
//-------------------------------------------------------- | ||
|
||
vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast( | ||
outInfo->Get(vtkDataObject::DATA_OBJECT())); | ||
output->ShallowCopy(clipperOutput); | ||
|
||
clipper->Delete(); | ||
} | ||
return 1; | ||
} | ||
|
||
int vtkMDHWSource::RequestInformation(vtkInformation *vtkNotUsed(request), vtkInformationVector **vtkNotUsed(inputVector), vtkInformationVector *outputVector) | ||
{ | ||
if(m_presenter == NULL && !m_wsName.empty()) | ||
{ | ||
m_presenter = new MDEWInMemoryLoadingPresenter(new MDLoadingViewAdapter<vtkMDHWSource>(this), new ADSWorkspaceProvider<Mantid::API::IMDEventWorkspace>, m_wsName); | ||
if(!m_presenter->canReadFile()) | ||
{ | ||
vtkErrorMacro(<<"Cannot fetch the specified workspace from Mantid ADS."); | ||
} | ||
else | ||
{ | ||
m_presenter->executeLoadMetadata(); | ||
setTimeRange(outputVector); | ||
} | ||
} | ||
return 1; | ||
} | ||
|
||
void vtkMDHWSource::PrintSelf(ostream& os, vtkIndent indent) | ||
{ | ||
this->Superclass::PrintSelf(os, indent); | ||
} | ||
|
||
/** Helper function to setup the time range. | ||
@param outputVector : vector onto which the time range will be set. | ||
*/ | ||
void vtkMDHWSource::setTimeRange(vtkInformationVector* outputVector) | ||
{ | ||
if(m_presenter->hasTDimensionAvailable()) | ||
{ | ||
vtkInformation *outInfo = outputVector->GetInformationObject(0); | ||
std::vector<double> timeStepValues = m_presenter->getTimeStepValues(); | ||
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), &timeStepValues[0], | ||
static_cast<int> (timeStepValues.size())); | ||
double timeRange[2]; | ||
timeRange[0] = timeStepValues.front(); | ||
timeRange[1] = timeStepValues.back(); | ||
|
||
outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2); | ||
} | ||
} | ||
|
||
/* | ||
Getter for the recursion depth. | ||
@return depth | ||
*/ | ||
size_t vtkMDHWSource::getRecursionDepth() const | ||
{ | ||
return this->m_depth; | ||
} | ||
|
||
/* | ||
Getter for the load in memory status | ||
@return true. | ||
*/ | ||
bool vtkMDHWSource::getLoadInMemory() const | ||
{ | ||
return true; | ||
} | ||
|
||
/*Getter for the time | ||
@return the time. | ||
*/ | ||
double vtkMDHWSource::getTime() const | ||
{ | ||
return m_time; | ||
} | ||
|
||
/* | ||
Setter for the algorithm progress. | ||
@param : | ||
*/ | ||
void vtkMDHWSource::updateAlgorithmProgress(double) | ||
{ | ||
} | ||
|
||
/* | ||
Getter for the workspace type name. | ||
*/ | ||
char* vtkMDHWSource::GetWorkspaceTypeName() | ||
{ | ||
if(m_presenter == NULL) | ||
{ | ||
return ""; | ||
} | ||
try | ||
{ | ||
//Forward request on to MVP presenter | ||
return const_cast<char*>(m_presenter->getWorkspaceTypeName().c_str()); | ||
} | ||
catch(std::runtime_error&) | ||
{ | ||
return ""; | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
Code/Mantid/Vates/ParaviewPlugins/ParaViewSources/MDHWSource/vtkMDHWSource.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#ifndef _vtkMDHWSource_h | ||
#define _vtkMDHWSource_h | ||
|
||
#include "vtkUnstructuredGridAlgorithm.h" | ||
#include <string> | ||
|
||
namespace Mantid | ||
{ | ||
namespace VATES | ||
{ | ||
class MDLoadingPresenter; | ||
} | ||
} | ||
|
||
/* Source for fetching Multidimensional Workspace out of the Mantid Analysis Data Service | ||
and converting them into vtkDataSets as part of the pipeline source. | ||
@date 01/12/2011 | ||
Copyright © 2007-9 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory | ||
This file is part of Mantid. | ||
Mantid is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 3 of the License, or | ||
(at your option) any later version. | ||
Mantid is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
File change history is stored at: <https://svn.mantidproject.org/mantid/trunk/Code/Mantid>. | ||
Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
*/ | ||
|
||
class VTK_EXPORT vtkMDHWSource : public vtkUnstructuredGridAlgorithm | ||
{ | ||
public: | ||
static vtkMDHWSource *New(); | ||
vtkTypeRevisionMacro(vtkMDHWSource,vtkUnstructuredGridAlgorithm); | ||
void PrintSelf(ostream& os, vtkIndent indent); | ||
|
||
void SetWsName(std::string wsName); | ||
void SetDepth(int depth); | ||
|
||
//------- MDLoadingView methods ---------------- | ||
virtual double getTime() const; | ||
virtual size_t getRecursionDepth() const; | ||
virtual bool getLoadInMemory() const; | ||
//---------------------------------------------- | ||
|
||
/// Update the algorithm progress. | ||
void updateAlgorithmProgress(double); | ||
/// Getter for the input geometry xml | ||
const char* GetInputGeometryXML(); | ||
/// Getter for the workspace type | ||
char* GetWorkspaceTypeName(); | ||
|
||
protected: | ||
vtkMDHWSource(); | ||
~vtkMDHWSource(); | ||
int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *); | ||
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); | ||
|
||
private: | ||
|
||
/// Name of the workspace. | ||
std::string m_wsName; | ||
|
||
/// Recursion depth. | ||
size_t m_depth; | ||
|
||
/// Time. | ||
double m_time; | ||
|
||
/// MVP presenter. | ||
Mantid::VATES::MDLoadingPresenter* m_presenter; | ||
|
||
vtkMDHWSource(const vtkMDHWSource&); | ||
void operator = (const vtkMDHWSource&); | ||
void setTimeRange(vtkInformationVector* outputVector); | ||
}; | ||
#endif |