image_view.cpp 1.56 KB
Newer Older
1 2 3 4 5 6 7 8

#include <memory>

#include <QString>
#include <QWidget>
#include <QHBoxLayout>
#include <QGridLayout>

Maksim Shabunin's avatar
Maksim Shabunin committed
9
#include <opencv2/core.hpp>
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

#include "../qtutil/accordion.hpp"
#include "../qtutil/zoomableimageoptpanel.hpp"
#include "../qtutil/zoomableimage.hpp"
#include "../qtutil/histogram.hpp"
#include "../qtutil/histogramoptpanel.hpp"
#include "../util/util.hpp"
#include "image_view.hpp"

namespace cvv
{
namespace view
{

ImageView::ImageView(const cv::Mat &image, QWidget *parent)
	    : QWidget{ parent }, image{nullptr}
{
	auto layout = util::make_unique<QHBoxLayout>();
	auto imageLayout = util::make_unique<QGridLayout>();
	auto accor = util::make_unique<qtutil::Accordion>();

	accor->setMinimumWidth(300);
	accor->setMaximumWidth(300);

	auto zoomim = util::make_unique<qtutil::ZoomableImage>();
	accor->insert(QString("ImageInformation:"),
		std::move(util::make_unique<qtutil::ZoomableOptPanel>(*zoomim,false)));
	zoomim->setMat(image);

	auto histogram = util::make_unique<qtutil::Histogram>();
	histogram->setMat(image);
	histogram->setVisible(false);
	connect(zoomim.get(), SIGNAL(updateArea(QRectF, qreal)), histogram.get(), SLOT(setArea(QRectF, qreal)));

	accor->insert(QString("Histogram:"), std::move(util::make_unique<qtutil::HistogramOptPanel>(*histogram)));

	this->image = (*zoomim);
	imageLayout->addWidget(zoomim.release(), 0, 0);
	imageLayout->addWidget(histogram.release(), 1, 0);
	layout->addWidget(accor.release());
	layout->addLayout(imageLayout.release());

	setLayout(layout.release());
}

void ImageView::showFullImage()
{
	image->showFullImage();
}


}} //namespaces