Skip to content

Commit

Permalink
refs #4201 Trivial conflict resolved
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/mantidproject/mantid

Conflicts:
	Code/Mantid/Framework/MDAlgorithms/test/ConvertToMDEventsUnitsConvTest.h
  • Loading branch information
abuts committed Jan 10, 2012
2 parents 45091f2 + 960dd98 commit 9f36532
Show file tree
Hide file tree
Showing 22 changed files with 354 additions and 105 deletions.
1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/ISpectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ namespace API
void addDetectorIDs(const std::set<detid_t> detIDs);
void addDetectorIDs(const std::vector<detid_t> detIDs);
void setDetectorID(const detid_t detID);

This comment has been minimized.

Copy link
@RussellTaylor

RussellTaylor Jan 10, 2012

Contributor

It's irritating that this non-change means that just about the entire software has to be rebuilt.
P.S. learning git rebase is encouraged.


bool hasDetectorID(const detid_t detID) const;

Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/API/src/IEventWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Mantid::API::IEventWorkspace_sptr IPropertyManager::getValue<Mantid::API::IEvent
}
else
{
std::string message = "Attempt to assign property "+ name +" to incorrect type. Expected EventWorkspace.";
std::string message = "Attempt to assign property "+ name +" to incorrect type. Expected IEventWorkspace.";
throw std::runtime_error(message);
}
}
Expand All @@ -46,7 +46,7 @@ Mantid::API::IEventWorkspace_const_sptr IPropertyManager::getValue<Mantid::API::
}
else
{
std::string message = "Attempt to assign property "+ name +" to incorrect type. Expected const EventWorkspace.";
std::string message = "Attempt to assign property "+ name +" to incorrect type. Expected const IEventWorkspace.";
throw std::runtime_error(message);
}
}
Expand Down
5 changes: 2 additions & 3 deletions Code/Mantid/Framework/Algorithms/src/AlignDetectorInTOF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ namespace Algorithms

std::vector<std::string> exts;
exts.push_back(".dat");
declareProperty(new FileProperty("CalibrationFile", "", FileProperty::OptionalLoad, exts),
"Optional: The .cal file containing the position correction factors. Either this or OffsetsWorkspace needs to be specified.");

declareProperty(new FileProperty("CalibrationFile", "", FileProperty::Load, exts),
"The .dat file containing the position correction factors. It is given by VULCAN instrument scientist, but not a Mantid calibration file. ");
}

//-----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace Mantid
declareProperty(new WorkspaceProperty<>("InputWorkspace","",Direction::Input,
new WorkspaceUnitValidator<>("dSpacing")),"A 2D workspace with X values of d-spacing");

declareProperty("DReference","2.0","Optional: enter a comma-separated list of the expected X-position of the centre of the peaks. Only peaks near these positions will be fitted." );
declareProperty("DReference","2.0","Enter a comma-separated list of the expected X-position of the centre of the peaks. Only peaks near these positions will be fitted." );

declareProperty(new FileProperty("GroupingFileName","", FileProperty::OptionalSave, ".cal"),
"Optional: The name of the output CalFile to save the generated OffsetsWorkspace." );
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MPIAlgorithms/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANTIDPATH=~/Mantid/Code/mpi-build/bin PYTHONPATH=$MANTIDPATH mpirun -np $2 python $1
MANTIDPATH=~/Code/Mantid/Code/mpi-framework/bin PYTHONPATH=$MANTIDPATH mpirun -np $2 python $1
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#include "MantidAPI/IEventWorkspace.h"
#include "MantidAPI/IEventList.h"
#include "MantidAPI/WorkspaceProperty.h"
#include "MantidPythonInterface/kernel/SingleValueTypeHandler.h"
#include "MantidPythonInterface/kernel/PropertyWithValue.h"

#include <boost/python/class.hpp>
#include <boost/python/register_ptr_to_python.hpp>

using Mantid::API::IEventWorkspace;
using Mantid::API::IEventWorkspace_sptr;
using Mantid::API::IEventList;
using Mantid::API::WorkspaceProperty;
using Mantid::API::IWorkspaceProperty;
using Mantid::Kernel::PropertyWithValue;
using namespace boost::python;

void export_IEventWorkspace()
Expand All @@ -24,3 +31,12 @@ void export_IEventWorkspace()

DECLARE_SINGLEVALUETYPEHANDLER(IEventWorkspace, Mantid::Kernel::DataItem_sptr);
}

void export_IEventWorkspaceProperty()
{
EXPORT_PROP_W_VALUE(IEventWorkspace_sptr, IEventWorkspace);
register_ptr_to_python<WorkspaceProperty<IEventWorkspace>*>();
class_<WorkspaceProperty<IEventWorkspace>, bases<PropertyWithValue<IEventWorkspace_sptr>,IWorkspaceProperty>,
boost::noncopyable>("WorkspaceProperty_IEventWorkspace", no_init)
;
}
25 changes: 23 additions & 2 deletions Code/Mantid/Framework/PythonInterface/mantid/simpleapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@
def version():
return "simpleapi - memory-based version"

def _is_workspace_property(prop):
"""
Returns true if the property is a workspace property.
Currently several properties , i.e WorspaceProperty<EventWorkspace>
cannot be recognised by Python so we have to resort to a name test
@param prop - A property object
@returns True if the property is considered to be of type workspace
"""
if isinstance(prop, api.IWorkspaceProperty):
return True
if 'Workspace' in prop.name: return True
# Doesn't look like a workspace property
return False

def get_additional_args(lhs, algm_obj):
"""
Return the extra arguments that are to be passed to the algorithm
Expand All @@ -55,7 +71,12 @@ def get_additional_args(lhs, algm_obj):
i = 0
while len(ret_names) > 0 and i < nprops:
p = output_props[i]
if isinstance(p,api.IWorkspaceProperty):
#
# Some algorithms declare properties as EventWorkspace and not its interface
# so Python doesn't know about it. Need to find a better way of
# dealing with WorkspaceProperty types. If they didn't multiple inherit
# that would help
if _is_workspace_property(p):
extra_args[p.name] = ret_names[0]
ret_names = ret_names[1:]
i += 1
Expand Down Expand Up @@ -84,7 +105,7 @@ def gather_returns(func_name, lhs, algm_obj, ignore=[]):
for name in algm_obj.outputProperties():
if name in ignore: continue
prop = algm_obj.getProperty(name)
if isinstance(prop, api.IWorkspaceProperty) and not algm_obj.isChild():
if not algm_obj.isChild() and _is_workspace_property(prop):
retvals.append(_ads[prop.valueAsStr])
else:
retvals.append(prop.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def test_alg_attrs_are_correct(self):
self.assertTrue(self._load.name(), 'Load')
self.assertTrue(self._load.version(), 1)
self.assertTrue(self._load.category(), 'DataHandling')


def test_get_unknown_property_raises_error(self):
self.assertRaises(RuntimeError, self._load.getProperty, "NotAProperty")

def test_alg_set_valid_prop_succeeds(self):
self._load.setProperty('Filename', 'LOQ48127.raw')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from testhelpers import run_algorithm, can_be_instantiated

from mantid.api import IEventWorkspace, IEventList
from mantid.api import (IEventWorkspace, IEventList, IWorkspaceProperty,
AlgorithmManager)

class IEventWorkspaceTest(unittest.TestCase):

Expand Down Expand Up @@ -34,6 +35,6 @@ def test_event_list_is_return_as_correct_type(self):
el = self._test_ws.getEventList(0)
self.assertTrue(isinstance(el, IEventList))
self.assertEquals(el.getNumberEvents(), 0)

if __name__ == '__main__':
unittest.main()
2 changes: 2 additions & 0 deletions Code/Mantid/MantidPlot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ set ( QTIPLOT_MOC_FILES src/ApplicationWindow.h
src/FunctionDialog.h
src/Graph3D.h
src/Graph.h
src/Grid.h
src/ImageDialog.h
src/ImageExportDialog.h
src/ImportASCIIDialog.h
Expand Down Expand Up @@ -825,6 +826,7 @@ add_custom_command ( TARGET MantidPlot POST_BUILD
set ( MANTIDPLOT_TEST_PY_FILES
MantidPlotSliceViewerTest.py
MantidPlot1DPlotTest.py
MantidPlotProxiesTest.py
)

if ( 0 )
Expand Down
3 changes: 2 additions & 1 deletion Code/Mantid/MantidPlot/FixBundle.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ file ( GLOB_RECURSE qtplugins ${bundle}/Contents/Frameworks/plugins/*.dylib )
file ( GLOB_RECURSE mtdqtplugins ${bundle}/plugins/*.dylib )
set ( mantidpydir ${bundle}/Contents/MacOS/mantid )
set ( mantidpy ${mantidpydir}/kernel/_kernel.so
${mantidpydir}/kernel/_dlopen.so
${mantidpydir}/geometry/_geometry.so
${mantidpydir}/api/_api.so )

Expand All @@ -16,6 +17,6 @@ set ( other_libs ${bundle}/Contents/MacOS/libMantidPythonAPI.so
${mtdqtplugins}
)

set ( dirs "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@" "@CMAKE_LIBRARY_PATH@" /Library/Frameworks /opt/intel/lib )
set ( dirs "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@" "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@/mantid/kernel" "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@/mantid/geometry" "@CMAKE_LIBRARY_PATH@" /Library/Frameworks /opt/intel/lib )

fixup_bundle ( "${bundle}" "${other_libs}" "${dirs}" )
5 changes: 3 additions & 2 deletions Code/Mantid/MantidPlot/mantidplotrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ def get_default_python_api():
# Adding this fixes that and appears to do no harm elsewhere
from mantidsimple import *
elif _api == 2:
from mantid import *
from mantid.simpleapi import *
from mantid.kernel.plugins import PyAlgLoader
# Make sure the Python algorithms are loaded as these all have to use the old API at the moment
loader = PyAlgLoader()
loader.load_modules()
# Create simple API
from mantid import *
from mantid.simpleapi import *
else:
raise Runtime("Unknown Python API version requested: %d" % _api)

Expand Down
40 changes: 24 additions & 16 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3098,11 +3098,11 @@ Note* ApplicationWindow::newNote(const QString& caption)

addMdiSubWindow(m);

connect(m, SIGNAL(modifiedWindow(MdiSubWindow*)), this, SLOT(modifiedProject(MdiSubWindow*)));
connect(m, SIGNAL(resizedWindow(MdiSubWindow*)),this,SLOT(modifiedProject(MdiSubWindow*)));
connect(m, SIGNAL(closedWindow(MdiSubWindow*)), this, SLOT(closeWindow(MdiSubWindow*)));
connect(m, SIGNAL(hiddenWindow(MdiSubWindow*)), this, SLOT(hideWindow(MdiSubWindow*)));
connect(m, SIGNAL(statusChanged(MdiSubWindow*)), this, SLOT(updateWindowStatus(MdiSubWindow*)));
//connect(m, SIGNAL(modifiedWindow(MdiSubWindow*)), this, SLOT(modifiedProject(MdiSubWindow*)));
//connect(m, SIGNAL(resizedWindow(MdiSubWindow*)),this,SLOT(modifiedProject(MdiSubWindow*)));
//connect(m, SIGNAL(closedWindow(MdiSubWindow*)), this, SLOT(closeWindow(MdiSubWindow*)));
//connect(m, SIGNAL(hiddenWindow(MdiSubWindow*)), this, SLOT(hideWindow(MdiSubWindow*)));
//connect(m, SIGNAL(statusChanged(MdiSubWindow*)), this, SLOT(updateWindowStatus(MdiSubWindow*)));

m->showNormal();
return m;
Expand Down Expand Up @@ -4501,7 +4501,8 @@ ApplicationWindow* ApplicationWindow::openProject(const QString& fn, bool factor
app->setListViewDate(caption, graph[3]);
plot->setBirthDate(graph[3]);

restoreWindowGeometry(app, plot, t.readLine());
//restoreWindowGeometry(app, plot, t.readLine());
t.readLine();
plot->blockSignals(true);

if (d_file_version > 71)
Expand Down Expand Up @@ -4776,7 +4777,7 @@ MdiSubWindow* ApplicationWindow::openTemplate(const QString& fn)
if (w){
dynamic_cast<MultiLayer*>(w)->setCols(cols);
dynamic_cast<MultiLayer*>(w)->setRows(rows);
restoreWindowGeometry(this, w, geometry);
//restoreWindowGeometry(this, w, geometry);
if (d_file_version > 83){
QStringList lst=t.readLine().split("\t", QString::SkipEmptyParts);
dynamic_cast<MultiLayer*>(w)->setMargins(lst[1].toInt(),lst[2].toInt(),lst[3].toInt(),lst[4].toInt());
Expand Down Expand Up @@ -4809,7 +4810,7 @@ MdiSubWindow* ApplicationWindow::openTemplate(const QString& fn)
while (!t.atEnd())
lst << t.readLine();
w->restore(lst);
restoreWindowGeometry(this, w, geometry);
//restoreWindowGeometry(this, w, geometry);
}
}
}
Expand Down Expand Up @@ -10695,7 +10696,7 @@ Note* ApplicationWindow::openNote(ApplicationWindow* app, const QStringList &fli
app->setListViewDate(caption, lst[1]);
w->setBirthDate(lst[1]);
}
restoreWindowGeometry(app, w, flist[1]);
//restoreWindowGeometry(app, w, flist[1]);

lst=flist[2].split("\t");
w->setWindowLabel(lst[1]);
Expand Down Expand Up @@ -10799,7 +10800,7 @@ void ApplicationWindow::openMantidMatrix(const QStringList &list)
QStringList fields = (*line).split("\t");
if (fields[0] == "geometry" || fields[0] == "tgeometry")
{
restoreWindowGeometry(this, m, *line);
//restoreWindowGeometry(this, m, *line);
}
}
}
Expand All @@ -10811,14 +10812,14 @@ void ApplicationWindow::openInstrumentWindow(const QStringList &list)
InstrumentWindow *insWin = mantidUI->getInstrumentView(wsName);
if(!insWin)
return;
insWin->show();
//insWin->show();
QStringList::const_iterator line = list.begin();
for (line++; line!=list.end(); ++line)
{
QStringList fields = (*line).split("\t");
if (fields[0] == "geometry" || fields[0] == "tgeometry")
{
restoreWindowGeometry(this, insWin, *line);
//restoreWindowGeometry(this, insWin, *line);
}
}
}
Expand Down Expand Up @@ -11791,7 +11792,7 @@ Graph3D* ApplicationWindow::openSurfacePlot(ApplicationWindow* app, const QStrin
app->setListViewDate(caption, date);
plot->setBirthDate(date);
plot->setIgnoreFonts(true);
restoreWindowGeometry(app, plot, lst[1]);
//restoreWindowGeometry(app, plot, lst[1]);

fList=lst[4].split("\t", QString::SkipEmptyParts);
plot->setGrid(fList[1].toInt());
Expand Down Expand Up @@ -14679,7 +14680,7 @@ Folder* ApplicationWindow::appendProject(const QString& fn, Folder* parentFolder
plot->setBirthDate(graph[3]);
plot->blockSignals(true);

restoreWindowGeometry(this, plot, t.readLine());
//restoreWindowGeometry(this, plot, t.readLine());

if (d_file_version > 71){
QStringList lst=t.readLine().split("\t");
Expand Down Expand Up @@ -15998,8 +15999,13 @@ void ApplicationWindow::cascade()
int y = 0;
QList<QMdiSubWindow*> windows = d_workspace->subWindowList(QMdiArea::StackingOrder);
foreach (QMdiSubWindow *w, windows){
MdiSubWindow* innerWidget = dynamic_cast<MdiSubWindow*>(w->widget());
if (!innerWidget)
{
throw std::runtime_error("A non-MdiSubWindow detected in the MDI area");
}
w->setActiveWindow();
dynamic_cast<MdiSubWindow*>(w)->setNormal();
innerWidget->setNormal();
w->setGeometry(x, y, w->geometry().width(), w->geometry().height());
w->raise();
x += xoffset;
Expand Down Expand Up @@ -17472,6 +17478,8 @@ void ApplicationWindow::removeFloatingWindow(FloatingWindow* w)
{
closeWindow(w->mdiSubWindow());
}
// Make the FloatingWindow delete itself
w->deleteLater();
}
}

Expand Down Expand Up @@ -17644,7 +17652,7 @@ bool ApplicationWindow::isDefaultFloating(const MdiSubWindow* w) const
bool ApplicationWindow::isDefaultFloating(const QString& aClassName) const
{
bool theDefault = false;
if (aClassName == "MultiLayer" || aClassName =="InstrumentWindow")
if (aClassName == "MultiLayer" || aClassName =="InstrumentWindow" || aClassName == "MdiSubWindow")
{
theDefault = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/Grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

#include <QPainter>

Grid::Grid() : QwtPlotGrid(),
Grid::Grid() : QObject(), QwtPlotGrid(),
d_maj_pen_y(QPen(Qt::blue, 0.5, Qt::SolidLine)),
d_min_pen_y(QPen(Qt::gray, 0.4, Qt::DotLine)),
mrkX(-1),
Expand Down
3 changes: 2 additions & 1 deletion Code/Mantid/MantidPlot/src/Grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
#include <qwt_plot_grid.h>
#include <qwt_plot_marker.h>

class Grid : public QwtPlotGrid
class Grid : public QObject, public QwtPlotGrid // Made a QObject just for our python proxies
{
Q_OBJECT
public:
Grid();

Expand Down

0 comments on commit 9f36532

Please sign in to comment.