From 14c26594bdd6d849bfd591abb94088da0113219c Mon Sep 17 00:00:00 2001 From: Janik Zikovsky <zikovskyjl@ornl.gov> Date: Mon, 3 Oct 2011 18:59:30 +0000 Subject: [PATCH] Refs #3882: Demo application for the SliceViewer gui. --- Code/Mantid/MantidPlot/CMakeLists.txt | 18 +++++-- .../Mantid/SliceViewer/DimensionSliceWidget.h | 26 ++++++++++ .../src/Mantid/SliceViewer/main.cpp | 52 +++++++++++++++++++ 3 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 Code/Mantid/MantidPlot/src/Mantid/SliceViewer/main.cpp diff --git a/Code/Mantid/MantidPlot/CMakeLists.txt b/Code/Mantid/MantidPlot/CMakeLists.txt index b2feca5873e..fd8d9ca73e7 100644 --- a/Code/Mantid/MantidPlot/CMakeLists.txt +++ b/Code/Mantid/MantidPlot/CMakeLists.txt @@ -59,7 +59,6 @@ set ( QTIPLOT_SRCS src/ApplicationWindow.cpp src/LineDialog.cpp src/LineProfileTool.cpp src/LogisticFit.cpp - src/main.cpp src/MatrixCommand.cpp src/Matrix.cpp src/MatrixDialog.cpp @@ -750,8 +749,21 @@ if ( APPLE ) set_source_files_properties(MANTID_RC_FILE PROPERTIES MACOSX_PACKAGE_LOCATION Resources) endif () -add_executable ( MantidPlot ${WIN_CONSOLE} MACOSX_BUNDLE ${ALL_SRC} ${INC_FILES} - ${QTIPLOT_C_SRC} ${UI_HDRS} ${RES_FILES} ${MANTID_RC_FILE} +add_executable ( MantidPlot ${WIN_CONSOLE} MACOSX_BUNDLE ${ALL_SRC} src/main.cpp + ${INC_FILES} ${QTIPLOT_C_SRC} ${UI_HDRS} ${RES_FILES} ${MANTID_RC_FILE} +) + + +# Extra, optional target for demoing a GUI element +add_executable ( SliceViewerDemo ${WIN_CONSOLE} MACOSX_BUNDLE ${ALL_SRC} src/Mantid/SliceViewer/main.cpp + ${INC_FILES} ${QTIPLOT_C_SRC} ${UI_HDRS} ${RES_FILES} ${MANTID_RC_FILE} ) +target_link_libraries ( SliceViewerDemo + ${CORE_MANTIDLIBS} MantidQtAPI MantidWidgets + QtPropertyBrowser ${QT_LIBRARIES} + ${QWT_LIBRARIES} ${QWTPLOT3D_LIBRARIES} + ${QSCINTILLA_LIBRARIES} + ${PYTHON_LIBRARIES} + ${ZLIB_LIBRARIES} ) # Library dependencies diff --git a/Code/Mantid/MantidPlot/src/Mantid/SliceViewer/DimensionSliceWidget.h b/Code/Mantid/MantidPlot/src/Mantid/SliceViewer/DimensionSliceWidget.h index 264eab1d2b0..cf1bb48da32 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/SliceViewer/DimensionSliceWidget.h +++ b/Code/Mantid/MantidPlot/src/Mantid/SliceViewer/DimensionSliceWidget.h @@ -3,6 +3,17 @@ #include <QtGui/QWidget> #include "ui_DimensionSliceWidget.h" +#include "MantidGeometry/MDGeometry/IMDDimension.h" + + +/** Widget for the 2D slice viewer. Select whether the dimension + * is X or Y, or if it is not one to be shown, where is the + * slice. + * Shows the dimension name and units + * + * @author Janik Zikovsky + * @date Oct 3, 2011 + */ class DimensionSliceWidget : public QWidget { @@ -12,8 +23,23 @@ public: DimensionSliceWidget(QWidget *parent = 0); ~DimensionSliceWidget(); + void setDimension(Mantid::Geometry::IMDDimension_sptr dim); + + double getSlicePoint() const + { return m_slicePoint; } + private: + /// Auto-gen UI class Ui::DimensionSliceWidgetClass ui; + + /// Sptr to the dimensions being displayed + Mantid::Geometry::IMDDimension_sptr m_dim; + + /// Which dimension is being shown. -1 = None, 0 = X, 1 = Y. 2+ reserved for higher dimensions + int m_shownDim; + + /// If the dimensions is not shown, where is the slice point? + double m_slicePoint; }; #endif // DIMENSIONSLICEWIDGET_H diff --git a/Code/Mantid/MantidPlot/src/Mantid/SliceViewer/main.cpp b/Code/Mantid/MantidPlot/src/Mantid/SliceViewer/main.cpp new file mode 100644 index 00000000000..bcda8e50d8d --- /dev/null +++ b/Code/Mantid/MantidPlot/src/Mantid/SliceViewer/main.cpp @@ -0,0 +1,52 @@ +#include <iostream> +#include <QApplication> +#include <QSplashScreen> +#include <QMessageBox> +#include <QDir> +#include <QThread> + +#include "ApplicationWindow.h" +#include "MantidKernel/Logger.h" +#include "MantidKernel/MantidVersion.h" + +#include "Mantid/MantidApplication.h" +#include "qmainwindow.h" +#include "Mantid/SliceViewer/SliceViewer.h" + + +/** Demo application for quickly testing the SliceViewer GUI. + * + * @author Janik Zikovsky + * @date Oct 3, 2011 + */ + + +/** Main application + * + * @param argc :: ignored + * @param argv :: ignored + * @return return code + */ +int main( int argc, char ** argv ) +{ + QApplication app(argc, argv); + app.setOrganizationName("JanikTech"); + app.setApplicationName("Application Example"); + QMainWindow * mainWin = new QMainWindow(); + + QFrame * frame = new QFrame(mainWin); + mainWin->setCentralWidget(frame); + + QLayout * layout = new QVBoxLayout(frame); + frame->setLayout(layout); + + SliceViewer * slicer = new SliceViewer(frame); + slicer->resize(600,600); + layout->addWidget(slicer); + + mainWin->move(100,100); + mainWin->resize(700, 700); + mainWin->show(); + return app.exec(); + +} -- GitLab