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

Refs #3364. New object panel.

parent 07fbbb77
No related branches found
No related tags found
No related merge requests found
add_subdirectory( EventNexusReaderObjectPanel )
add_subdirectory( SQWEventReaderObjectPanel )
add_subdirectory( RebinningCutterObjectPanel )
add_subdirectory( RebinningCutterToolBarExtension )
add_subdirectory( QtWidgets )
......@@ -9,9 +9,6 @@ qt4_wrap_cpp( MOC_SRCS EventNexusReaderObjectPanel.h )
add_paraview_object_panel( IFACES IFACE_SRCS
CLASS_NAME EventNexusReaderObjectPanel
XML_NAME EventNexusReader XML_GROUP sources )
add_paraview_object_panel( IFACES IFACE_SRCS
CLASS_NAME EventNexusReaderObjectPanel
XML_NAME SQWEventReader XML_GROUP sources )
add_paraview_plugin( MantidParaViewEventNexusReaderObjectPanel "1.0"
GUI_INTERFACES ${IFACES}
SOURCES ${MOC_SRCS} ${IFACE_SRCS} ${INCLUDE_FILES}
......
......@@ -4,7 +4,7 @@
/**
Adds and removes from Paraview's autogenerated object panel for the Rebinning Cutting filter.
Adds and removes from Paraview's autogenerated object panel for the Event-based reader/filter.
@author Owen Arnold, Tessella plc
@date 17/03/2011
......
# Include Qt widgets
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../QtWidgets )
# So that source file shows in VS.
set( INCLUDE_FILES SQWEventReaderObjectPanel.h )
set( SRC_FILES SQWEventReaderObjectPanel.cxx )
qt4_wrap_cpp( MOC_SRCS SQWEventReaderObjectPanel.h )
add_paraview_object_panel( IFACES IFACE_SRCS
CLASS_NAME SQWEventReaderObjectPanel
XML_NAME EventNexusReader XML_GROUP sources )
add_paraview_object_panel( IFACES IFACE_SRCS
CLASS_NAME SQWEventReaderObjectPanel
XML_NAME SQWEventReader XML_GROUP sources )
add_paraview_plugin( MantidParaViewSQWEventReaderObjectPanel "1.0"
GUI_INTERFACES ${IFACES}
SOURCES ${MOC_SRCS} ${IFACE_SRCS} ${INCLUDE_FILES}
${SRC_FILES} )
target_link_libraries( MantidParaViewSQWEventReaderObjectPanel
MantidParaViewQtWidgets )
# Put library into subfolder.
output_binary_to( MantidParaViewSQWEventReaderObjectPanel ${PVPLUGINS_DIR})
install( TARGETS MantidParaViewSQWEventReaderObjectPanel ${TARGET_TYPE} DESTINATION ${PVPLUGINS_DIR} )
#include "SQWEventReaderObjectPanel.h"
#include "pqObjectPanelInterface.h"
#include "pqPropertyManager.h"
#include "pqNamedWidgets.h"
#include "vtkSMStringVectorProperty.h"
#include "vtkSMDoubleVectorProperty.h"
#include <QLayout>
#include <QMessageBox>
#include <QCheckBox>
#include <QGridLayout>
#include "GeometryWidget.h"
#include "ThresholdRangeWidget.h"
#include "MantidGeometry/MDGeometry/MDGeometryXMLParser.h"
#include "MantidVatesAPI/SynchronisingGeometryPresenter.h"
using namespace Mantid::VATES;
using namespace Mantid::Geometry;
SQWEventReaderObjectPanel::SQWEventReaderObjectPanel(pqProxy* pxy, QWidget* p) :
pqAutoGeneratedObjectPanel(pxy, p), m_cachedMinThreshold(0), m_cachedMaxThreshold(0), m_geometryXMLString(""), m_geometryWidget(NULL), m_thresholdWidget(NULL)
{
//Auto generated widgets are replaced by Custom Widgets. Autogenerated ones need to be removed.
removeAutoGeneratedWidgets();
}
/// Event handler for framework event.
void SQWEventReaderObjectPanel::updateInformationAndDomains()
{
this->proxy()->UpdatePropertyInformation();
QGridLayout* gLayout = dynamic_cast<QGridLayout*>(this->layout());
try
{
this->constructThresholdRanges(gLayout);
this->constructGeometry(gLayout);
}
catch(std::exception& ex)
{
UNUSED_ARG(ex);
QMessageBox::information(NULL, "Setup Not possible.",
"Could not interpret metadata. Are you using a rebinning source? Check field data.");
}
}
void SQWEventReaderObjectPanel::constructGeometry(QGridLayout* gLayout)
{
vtkSMStringVectorProperty* inputGeometryProperty = vtkSMStringVectorProperty::SafeDownCast(
this->proxy()->GetProperty("InputGeometryXML"));
std::string geometryXMLString = inputGeometryProperty->GetElement(0);
if(m_geometryXMLString != geometryXMLString) //Only attempt to reconstruct the geometry widget if the xml has changed.
{
MDGeometryXMLParser xmlParser(geometryXMLString);
xmlParser.execute();
//Empty geometry widget added to layout.
if(m_geometryWidget != NULL)
{
this->layout()->removeWidget(m_geometryWidget);
delete m_geometryWidget;
}
// Construct custom widget instance.
m_geometryWidget = new GeometryWidget(new SynchronisingGeometryPresenter(xmlParser), false);
gLayout->addWidget(m_geometryWidget, gLayout->rowCount() + 1, 0, Qt::AlignLeft);
connect(m_geometryWidget, SIGNAL(ignoreBinChanges()), this, SLOT(ignoreBinChangesListner()));
// Property used as setter.
vtkSMProperty * appliedGeometryXML = this->proxy()->GetProperty("AppliedGeometryXML");
//Hook up geometry change event to listener on filter.
this->propertyManager()->registerLink(m_geometryWidget, "GeometryXML",
SIGNAL(valueChanged()), this->proxy(), appliedGeometryXML);
m_geometryXMLString = geometryXMLString;
}
}
void SQWEventReaderObjectPanel::constructThresholdRanges(QGridLayout* gLayout)
{
// Access getter property to extract original input max threshold value.
vtkSMDoubleVectorProperty* inputMaxThresholdProperty = vtkSMDoubleVectorProperty::SafeDownCast(
this->proxy()->GetProperty("InputMaxThreshold"));
double inputMaxThreshold = inputMaxThresholdProperty->GetElement(0);
// Access getter property to extract original input min threshold value.
vtkSMDoubleVectorProperty* inputMinThresholdProperty = vtkSMDoubleVectorProperty::SafeDownCast(
this->proxy()->GetProperty("InputMinThreshold"));
double inputMinThreshold = inputMinThresholdProperty->GetElement(0);
if(inputMaxThreshold != m_cachedMaxThreshold || inputMinThreshold != m_cachedMinThreshold)
{
if(m_thresholdWidget == NULL)
{
m_thresholdWidget = new ThresholdRangeWidget(inputMinThreshold, inputMaxThreshold);
gLayout->addWidget(m_thresholdWidget, gLayout->rowCount() + 1, 0, Qt::AlignCenter);
}
else
{
m_thresholdWidget->setMaximum(inputMaxThreshold);
m_thresholdWidget->setMinimum(inputMinThreshold);
}
// Property used as setter
vtkSMProperty * minThreshold = this->proxy()->GetProperty("MinThreshold");
// Property used as setter
vtkSMProperty * maxThreshold = this->proxy()->GetProperty("MaxThreshold");
// Property used as setter
vtkSMProperty * rangeStrategy = this->proxy()->GetProperty("ThresholdRangeStrategyIndex");
// Hook-up events to PV properties.
this->propertyManager()->registerLink(m_thresholdWidget, "MinSignal",
SIGNAL(minChanged()), this->proxy(), minThreshold);
// Hook-up events to PV properties.
this->propertyManager()->registerLink(m_thresholdWidget, "MaxSignal",
SIGNAL(maxChanged()), this->proxy(), maxThreshold);
// Hook-up events to PV properties.
this->propertyManager()->registerLink(m_thresholdWidget, "ChosenStrategy",
SIGNAL(chosenStrategyChanged()), this->proxy(), rangeStrategy);
m_cachedMaxThreshold = inputMaxThreshold;
m_cachedMinThreshold = inputMinThreshold;
}
}
/// Direct removal of autogenerated widgets.
void SQWEventReaderObjectPanel::removeAutoGeneratedWidgets()
{
popWidget(); // Autogenerated Geometry QLineEdit
popWidget(); // Autogenerated Geometry QLabel
popWidget(); // Autogenerated Max threshold QLineEdit
popWidget(); // Autogenerated Max threshold QLabel
popWidget(); // Autogenerated Min threshold QLineEdit
popWidget(); // Autogenerated Min threshold QLabel
popWidget(); // Autogenerated User defined ComboBox.
popWidget(); // Autogenerated User defined ComboBox.
}
/// Pop widgets off the layout and hide them.
void SQWEventReaderObjectPanel::popWidget()
{
unsigned int size = layout()->count();
if(size >= 1)
{
//Pop the last widget off the layout and hide it.
QLayoutItem* pLayoutItem = layout()->itemAt(size - 1);
QWidget* pWidget = pLayoutItem->widget();
if (NULL == pWidget)
{
throw std::domain_error(
"Error ::popWidget(). Attempting to pop a non-widget object off the layout!");
}
else
{
pWidget->setHidden(true);
this->layout()->removeItem(pLayoutItem);
}
}
}
/// Listener for ignore bin changes.
void SQWEventReaderObjectPanel::ignoreBinChangesListner()
{
QLayoutItem *child;
unsigned int size = layout()->count();
for(unsigned int i = 0; i < size; i++)
{
child = layout()->itemAt(i);
QWidget* pWidget = child->widget();
if (NULL != pWidget) // capability query of layout item.
{
QCheckBox* checkBox;
if((checkBox = dynamic_cast<QCheckBox*>(pWidget)) != NULL) //capability query of widget.
{
// Apply Clip check box set to unchecked.
checkBox->setChecked(false);
break;
}
}
}
}
#include "pqAutoGeneratedObjectPanel.h"
#include "MantidKernel/System.h"
/**
Adds and removes from Paraview's autogenerated object panel for the Event based SQW reader/rebinner.
@author Owen Arnold, Tessella plc
@date 15/07/2011
Copyright &copy; 2010 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>
*/
//Forward declarations
class GeometryWidget;
class ThresholdRangeWidget;
class DLLExport SQWEventReaderObjectPanel : public pqAutoGeneratedObjectPanel
{
Q_OBJECT
private:
/// cached min threshold.
double m_cachedMinThreshold;
/// cached max threshold.
double m_cachedMaxThreshold;
/// cached geometry xml string.
std::string m_geometryXMLString;
/// Pointer to custom geometry widget.
GeometryWidget* m_geometryWidget;
/// Pointer to custom threshold range widget.
ThresholdRangeWidget* m_thresholdWidget;
private slots:
/// Handler for ignoring bin changes. i.e.
void ignoreBinChangesListner();
public:
/// Constructor
SQWEventReaderObjectPanel(pqProxy* pxy, QWidget* p);
/// Framework overriden method.
void updateInformationAndDomains();
/// Remove selected auto-generated widgets
void removeAutoGeneratedWidgets();
/// Pop the widget off the layout
void popWidget();
/// Construct threshold ranges and link-up with properties
void constructThresholdRanges(QGridLayout* gLayout);
/// Construct geometry widgets and link-up with properties
void constructGeometry(QGridLayout* gLayout);
};
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