Skip to content

Commit

Permalink
Check for correct property. Refs #8103
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiSavici committed Oct 10, 2013
1 parent 8cd2655 commit 0f180cb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ namespace Algorithms
virtual int version() const { return 1;};
/// Algorithm's category for identification
virtual const std::string category() const { return "Sample;Utility\\Workspaces;DataHandling";}

/// @inheritdocs
virtual std::map<std::string, std::string> validateInputs();
private:
/// Sets documentation strings for this algorithm
virtual void initDocs();
Expand All @@ -66,8 +67,6 @@ namespace Algorithms
/// Function to copy information from one sample to another
void copyParameters(API::Sample& from, API::Sample& to, bool nameFlag, bool materialFlag, bool environmentFlag, bool shapeFlag, bool latticeFlag, bool orientationOnlyFlag);



};


Expand Down
21 changes: 15 additions & 6 deletions Code/Mantid/Framework/Algorithms/src/CopySample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ One can copy the orientation matrix only. To do this, select both CopyLattice an
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidAPI/SampleEnvironment.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include "MantidKernel/VisibleWhenProperty.h"
#include "MantidKernel/EnabledWhenProperty.h"
namespace Mantid
{
namespace Algorithms
Expand Down Expand Up @@ -66,11 +66,24 @@ namespace Algorithms
declareProperty(new PropertyWithValue<bool>("CopyShape",true,Direction::Input),"Copy the sample shape" );
declareProperty(new PropertyWithValue<bool>("CopyLattice",true,Direction::Input),"Copy the sample oriented lattice" );
declareProperty(new PropertyWithValue<bool>("CopyOrientationOnly",false,Direction::Input),"Copy the U matrix only, if both origin and destination have oriented lattices" );
setPropertySettings("CopyOrientationOnly",new Kernel::VisibleWhenProperty("CopyLattice",IS_EQUAL_TO,"1"));
setPropertySettings("CopyOrientationOnly",new Kernel::EnabledWhenProperty("CopyLattice",IS_EQUAL_TO,"1"));
declareProperty(new PropertyWithValue<int>("MDInputSampleNumber",0,Direction::Input),"The number of the sample to be copied from, for an MD workspace (starting from 0)" );
declareProperty(new PropertyWithValue<int>("MDOutputSampleNumber",EMPTY_INT(),Direction::Input),"The number of the sample to be copied to for an MD workspace (starting from 0). No number, or negative number, means that it will copy to all samples" );
}


std::map<std::string, std::string> CopySample::validateInputs()
{
std::map<std::string, std::string> result;
const bool copyLattice = getProperty("CopyLattice");
const bool copyOrientationOnly = getProperty("CopyOrientationOnly");
if (copyOrientationOnly && !copyLattice)
{
result["CopyLattice"] = "Need to check CopyLattice if CopyOrientationOnly is checked";
}
return result;
}

//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
Expand Down Expand Up @@ -165,10 +178,6 @@ namespace Algorithms
to.setOrientedLattice(new Geometry::OrientedLattice(from.getOrientedLattice()));
}
}
if ((!latticeFlag)&& orientationOnlyFlag)
{
throw std::runtime_error("CopyOrientationOnly flag is set to true, but CopyLattice is false");
}

}

Expand Down

0 comments on commit 0f180cb

Please sign in to comment.