Skip to content

Commit

Permalink
Refs #3803. Make a new MuonFitPropertyBrowser.
Browse files Browse the repository at this point in the history
Inherit from FitPropertyBrowser and be modified for muon use.
  • Loading branch information
Robert-Whitley committed Feb 28, 2012
1 parent 954f35b commit 0f66f22
Show file tree
Hide file tree
Showing 15 changed files with 901 additions and 320 deletions.
3 changes: 2 additions & 1 deletion Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
#include "MantidQtMantidWidgets/ICatMyDataSearch.h"
#include "MantidQtMantidWidgets/ICatAdvancedSearch.h"
#include "MantidQtMantidWidgets/FitPropertyBrowser.h"
#include "MantidQtMantidWidgets/MuonFitPropertyBrowser.h"

#include "MantidKernel/ConfigService.h"
#include "MantidKernel/Logger.h"
Expand Down Expand Up @@ -17082,7 +17083,7 @@ void ApplicationWindow::runConnectFitting(MantidQt::MantidWidgets::FitPropertyBr
foreach(Graph *g, layers)
{
// Go through and set up the PeakPickerTool for the new graph
PeakPickerTool* ppicker = new PeakPickerTool(g, fpb, mantidUI, true);
PeakPickerTool* ppicker = new PeakPickerTool(g, fpb, mantidUI, true, true);
g->setActiveTool(ppicker);
}
}
Expand Down
7 changes: 5 additions & 2 deletions Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,11 @@ void MantidUI::init()
m_exploreAlgorithms->update();
try
{
m_fitFunction = new MantidQt::MantidWidgets::FitPropertyBrowser(m_appWindow, m_appWindow->mantidUI, false);
// m_fitFunction->init();
m_fitFunction = new MantidQt::MantidWidgets::FitPropertyBrowser(m_appWindow, m_appWindow->mantidUI);
m_fitFunction->init();
// this make the progress bar work with Fit algorithm running form the fit browser
connect(m_fitFunction,SIGNAL(executeFit(QString,QMap<QString,QString>,Mantid::API::AlgorithmObserver*)),
this,SLOT(executeAlgorithm(QString,QMap<QString,QString>,Mantid::API::AlgorithmObserver*)));
m_fitFunction->hide();
m_appWindow->addDockWidget( Qt::LeftDockWidgetArea, m_fitFunction );

Expand Down
5 changes: 3 additions & 2 deletions Code/Mantid/MantidPlot/src/Mantid/PeakPickerTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "MantidMatrixCurve.h"
#include "MantidUI.h"
#include "MantidQtMantidWidgets/FitPropertyBrowser.h"
#include "MantidQtMantidWidgets/MuonFitPropertyBrowser.h"
#include "../FunctionCurve.h"
#include "MantidQtMantidWidgets/PropertyHandler.h"

Expand All @@ -20,7 +21,7 @@

#include <iostream>

PeakPickerTool::PeakPickerTool(Graph *graph, MantidQt::MantidWidgets::FitPropertyBrowser *fitPropertyBrowser, MantidUI *mantidUI, bool showFitPropertyBrowser) :
PeakPickerTool::PeakPickerTool(Graph *graph, MantidQt::MantidWidgets::FitPropertyBrowser *fitPropertyBrowser, MantidUI *mantidUI, bool showFitPropertyBrowser, bool customInterface) :
QwtPlotPicker(graph->plotWidget()->canvas()),
PlotToolInterface(graph),
m_fitPropertyBrowser(fitPropertyBrowser),
Expand Down Expand Up @@ -84,7 +85,7 @@ m_width_set(true),m_width(0),m_addingPeak(false),m_resetting(false)
{
m_init = true;
// If part of custom interface (i.e muon analysis)
if (m_fitPropertyBrowser->isCustomFittings())
if (customInterface)
{
// Set the vertical lines to correspond to the StartX and EndX stated on the custom interface.
xMin(m_fitPropertyBrowser->startX());
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidPlot/src/Mantid/PeakPickerTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class PeakPickerTool : public QwtPlotPicker, public PlotToolInterface, public Qw
Q_OBJECT
public:
/// Constructor
PeakPickerTool(Graph *graph, MantidQt::MantidWidgets::FitPropertyBrowser *fitPropertyBrowser, MantidUI *mantidUI, bool showFitPropertyBrowser=true);
PeakPickerTool(Graph *graph, MantidQt::MantidWidgets::FitPropertyBrowser *fitPropertyBrowser, MantidUI *mantidUI, bool showFitPropertyBrowser=true, bool customInterface=false);
/// Destructor
~PeakPickerTool();
/// Runtime type identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1389,16 +1389,6 @@
<string>Data Analysis</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="MantidQt::MantidWidgets::FitPropertyBrowser" name="fitBrowser">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
Expand Down Expand Up @@ -1432,6 +1422,16 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="MantidQt::MantidWidgets::MuonFitPropertyBrowser" name="fitBrowser">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
Expand Down Expand Up @@ -2089,7 +2089,11 @@
<class>MantidQt::MantidWidgets::FitPropertyBrowser</class>
<extends>QDockWidget</extends>
<header>MantidQtMantidWidgets/FitPropertyBrowser.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>MantidQt::MantidWidgets::MuonFitPropertyBrowser</class>
<extends>MantidQt::MantidWidgets::FitPropertyBrowser</extends>
<header>MantidQtMantidWidgets/MuonFitPropertyBrowser.h</header>
</customwidget>
</customwidgets>
<tabstops>
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/MantidQt/CustomInterfaces/src/MuonAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "MantidQtCustomInterfaces/IO_MuonGrouping.h"
#include "MantidQtAPI/FileDialogHandler.h"
#include "MantidQtMantidWidgets/FitPropertyBrowser.h"
#include "MantidQtMantidWidgets/MuonFitPropertyBrowser.h"

#include "MantidKernel/ConfigService.h"
#include "MantidKernel/Logger.h"
Expand Down Expand Up @@ -88,6 +89,8 @@ void MuonAnalysis::initLayout()
{
m_uiForm.setupUi(this);

m_uiForm.fitBrowser->init();

// alow appending files
m_uiForm.mwRunFiles->allowMultipleFiles(true);

Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/MantidQt/DesignerPlugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ include ( ${QT_USE_FILE} )
set ( SRC_FILES src/FileFinderPlugin.cpp
src/FitBrowserPlugin.cpp
src/InstrumentSelectorPlugin.cpp
src/MuonFitBrowserPlugin.cpp
src/PluginCollectionInterface.cpp
src/WorkspaceSelectorPlugin.cpp )

# Include files aren't required, but this makes them appear in Visual Studio
set ( INC_FILES inc/MantidQtDesignerPlugins/FileFinderPlugin.h
inc/MantidQtDesignerPlugins/FitBrowserPlugin.h
inc/MantidQtDesignerPlugins/InstrumentSelectorPlugin.h
inc/MantidQtDesignerPlugins/MuonFitBrowserPlugin.h
inc/MantidQtDesignerPlugins/PluginCollectionInterface.h
inc/MantidQtDesignerPlugins/WorkspaceSelectorPlugin.h )

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifndef MUONFITBROWSERPLUGIN_H
#define MUONFITBROWSERPLUGIN_H

#include <QDesignerCustomWidgetInterface>

/**
The MuonFitBrowserPlugin creates a Qt designer plugin of the FitPropertyBrowser.
@author Robert Whitley, ISIS, RAL
@date 27/02/2012
Copyright &copy; 2010-12 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>
*/
class MuonFitBrowserPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)

public:
/// Default constructor
MuonFitBrowserPlugin(QObject *parent = 0);
/// Initialize the plugin
void initialize(QDesignerFormEditorInterface *core);
/// Returns a pointer to a newly constructed widget for this plugin wraps
QWidget *createWidget(QWidget *parent);
/// Returns if the plugin is initliaized
bool isInitialized() const;
/// Returns if this plugins is able to contain other widgets
bool isContainer() const;
/// Returns the fully-qualified class name
QString name() const;
/// Returns the group name within the designer
QString group() const;
/// Returns the icon to use
QIcon icon() const;
/// Returns a tool tip for the widget
QString toolTip() const;
/// Returns a short description of the widget
QString whatsThis() const;
/// Returns the include file that appears at the top of the generated .h file
QString includeFile() const;
/// Returns the XML that defines the widget and its properties
QString domXml() const;

private:
/// Are we initialized?
bool m_initialized;
};

#endif
119 changes: 119 additions & 0 deletions Code/Mantid/MantidQt/DesignerPlugins/src/MuonFitBrowserPlugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#include "MantidQtMantidWidgets/MuonFitPropertyBrowser.h"
#include "MantidQtDesignerPlugins/MuonFitBrowserPlugin.h"
#include <QDesignerFormEditorInterface>
#include <QtPlugin>


using namespace MantidQt::MantidWidgets;

/**
* Default constructor
* @param parent :: The parent of the plugin (default: NULL)
*/
MuonFitBrowserPlugin::MuonFitBrowserPlugin(QObject *parent) : QObject(parent), m_initialized(false)
{
}

/**
* Initialize the plugin
* @param formEditor :: A pointer to the interface that will control this plugin
*/
void MuonFitBrowserPlugin::initialize(QDesignerFormEditorInterface * formEditor)
{
(void) formEditor;
if (m_initialized)
{
return;
}
m_initialized = true;
}

/**
* Create a widget of the type wrapped by the plugin
* @param parent :: The parent widget
* @returns A newly constructed widget for the wrapped type.
*/
QWidget *MuonFitBrowserPlugin::createWidget(QWidget *parent)
{
return new MuonFitPropertyBrowser(parent);
}

/**
* Returns whether the plugin initialized or not
* @returns True if initialize() has been called, false otherwise
*/
bool MuonFitBrowserPlugin::isInitialized() const
{
return m_initialized;
}

/**
* Returns whether this widget can contain other widgets
* @returns True if other widgets can be placed within this widget, false otherwise
*/
bool MuonFitBrowserPlugin::isContainer() const
{
return false;
}

/**
* Returns the class name of the widget that this plugin manages
* @returns A string containing the fully qualified class name of the widget
*/
QString MuonFitBrowserPlugin::name() const
{
return "MantidQt::MantidWidgets::MuonFitPropertyBrowser";
}

/**
* Returns the group within the designer that this plugin should be placed
* @returns The name of the group of widgets in the designer
*/
QString MuonFitBrowserPlugin::group() const
{
return "MantidWidgets";
}

/**
* Returns the icon to display in the designer
* @returns An icon that is used within the designer
*/
QIcon MuonFitBrowserPlugin::icon() const
{
return QIcon();
}

/**
* The tooltip for the widget
* @returns A string containing the tooltip for this widget
*/
QString MuonFitBrowserPlugin::toolTip() const
{
return "The menu for fitting functions within Muon Analysis";
}

/** A short description of the widget
* @returns A string containing a short description of the widget
*/
QString MuonFitBrowserPlugin::whatsThis() const
{
return "The menu for fitting functions within Muon Analysis";
}

/**
* The include file to use when generating the header file
* @returns A string containing the path to the widget's header file
*/
QString MuonFitBrowserPlugin::includeFile() const
{
return "MantidQtMantidWidgets/MuonFitPropertyBrowser.h";
}

/**
* Returns the XML used to define the widget in the designer
* @returns A string containing the XML for the widget
*/
QString MuonFitBrowserPlugin::domXml() const
{
return "<widget class=\"MantidQt::MantidWidgets::MuonFitPropertyBrowser\" name=\"fitBrowser\" />";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "MantidQtDesignerPlugins/InstrumentSelectorPlugin.h"
#include "MantidQtDesignerPlugins/WorkspaceSelectorPlugin.h"
#include "MantidQtDesignerPlugins/FitBrowserPlugin.h"
#include "MantidQtDesignerPlugins/MuonFitBrowserPlugin.h"


Q_EXPORT_PLUGIN2(LIBRARY_NAME, PluginCollectionInterface)
Expand All @@ -24,6 +25,7 @@ PluginCollectionInterface::PluginCollectionInterface(QObject *parent) : QObject(
// development stage - only uncomment once they plugin
// can be can be dragged in without breaking designer
m_widgets.append(new FitBrowserPlugin(this));
m_widgets.append(new MuonFitBrowserPlugin(this));
}

/**
Expand Down

0 comments on commit 0f66f22

Please sign in to comment.