#include "HistogramMain.qo.h"
#include <guitools/Histogram/BinPlotWidget.qo.h>
#include <guitools/Histogram/ColorPreferences.qo.h>
#include <images/Images/ImageInterface.h>
#include <images/Regions/ImageRegion.h>
using namespace casacore;
HistogramMain::HistogramMain(bool showFileLoader, bool fitControls,
bool rangeControls, bool plotModeControls, QWidget *parent)
: QMainWindow(parent), fileLoader(this),
logger(LogOrigin("CASA", "Histogram")){
setWindowTitle( "Histogram Tool");
QLayout* mainLayout = ui.centralwidget->layout();
if ( mainLayout == NULL ){
mainLayout = new QHBoxLayout();
mainLayout->setContentsMargins(5,1,1,1);
plotWidget = new BinPlotWidget( fitControls, rangeControls,
plotModeControls, this );
mainLayout->addWidget( plotWidget );
ui.centralwidget->setLayout( mainLayout );
preferencesColor = new ColorPreferences( this );
preferencesColor->setFitColorsVisible( fitControls );
ui.toolBar->removeAction( ui.actionImageFile );
connect(ui.actionImageFile, SIGNAL(triggered()), this, SLOT(openFileLoader()));
connect( &fileLoader, SIGNAL(imageFileChanged()), this, SLOT(imageFileChanged()));
connect(ui.actionColor, SIGNAL(triggered()), this, SLOT(openColorPreferences()));
connect( preferencesColor, SIGNAL(colorsChanged()), this, SLOT(colorsChanged()));
connect(ui.actionSave, SIGNAL(triggered()), this, SLOT(openHistogramSaver()));
connect( &histogramSaver, SIGNAL(savePing(const QString&,int,int)), plotWidget, SLOT(toPing(const QString&,int,int)));
connect( &histogramSaver, SIGNAL(saveAscii(const QString&)), plotWidget, SLOT(toAscii(const QString&)));
connect( plotWidget, SIGNAL(postStatusMessage(const QString&)), this, SLOT(postStatusMessage(const QString&)));
connect( plotWidget, SIGNAL(rangeChanged()), this, SIGNAL(rangeChanged()));
plotWidget->addZoomActions( rangeControls, ui.menuZoom );
plotWidget->addDisplayActions( ui.menuDisplay, NULL );
plotWidget->addPlotModeActions( ui.menuConfigure, NULL, NULL);
preferencesColor->setMultipleHistogramColorsVisible( false );
plotWidget->setDisplayPlotTitle( true );
plotWidget->setDisplayAxisTitles( true );
bool HistogramMain::setImage(std::shared_ptr<const ImageInterface<Float> > img ){
bool imageSet = plotWidget->setImage( img );