18 #include <QGridLayout>
19 #include <QWebChannel>
20 #include <QWebEngineView>
28 class QmitkC3jsWidget::Impl final
31 explicit Impl(QWidget* parent);
34 Impl(
const Impl&) =
delete;
35 Impl& operator=(
const Impl&) =
delete;
37 QWebChannel* GetWebChannel();
39 void ClearJavaScriptChart();
40 void initializeJavaScriptChart();
41 void callJavaScriptFuntion(QString command);
53 QWebChannel* m_WebChannel;
54 QWebEngineView* m_WebEngineView;
73 QmitkC3jsWidget::Impl::Impl(QWidget* parent)
74 : m_WebChannel(new QWebChannel(parent)),
75 m_WebEngineView(new QWebEngineView(parent)),
79 m_WebEngineView->setContextMenuPolicy(Qt::NoContextMenu);
82 m_WebEngineView->setUrl(QUrl(QStringLiteral(
"qrc:///C3js/empty.html")));
83 m_WebEngineView->page()->setWebChannel(m_WebChannel);
85 connect( m_WebEngineView, SIGNAL( loadFinished(
bool) ), parent, SLOT( OnLoadFinished(
bool) ) );
87 auto layout =
new QGridLayout(parent);
89 layout->addWidget(m_WebEngineView);
91 parent->setLayout(layout);
94 QmitkC3jsWidget::Impl::~Impl()
98 QWebChannel* QmitkC3jsWidget::Impl::GetWebChannel()
110 void QmitkC3jsWidget::Impl::callJavaScriptFuntion(QString command)
112 m_WebEngineView->page()->runJavaScript(command);
115 void QmitkC3jsWidget::Impl::ClearJavaScriptChart()
117 m_WebEngineView->setUrl(QUrl(QStringLiteral(
"qrc:///C3js/empty.html")));
120 void QmitkC3jsWidget::Impl::initializeJavaScriptChart()
122 m_WebChannel->registerObject(QStringLiteral(
"initValues"), &m_c3Data);
123 m_WebEngineView->load(QUrl(QStringLiteral(
"qrc:///C3js/QmitkC3jsWidget.html")));
130 if (!
id.isEmpty() &&
object !=
nullptr)
131 m_Impl->GetWebChannel()->registerObject(
id,
object);
148 QString command = QString(
"transformView('" + transformTo +
"')");
149 m_Impl->callJavaScriptFuntion(command);
154 m_Impl->callJavaScriptFuntion(command);
159 this->m_Impl->GetC3Data()->SetAppearance(useLineChart, showSubChart);
165 this->m_Impl->GetC3Data()->SetHistogram(histogram);
175 this->m_Impl->GetC3Data()->ClearData();
178 bool firstValue =
false;
180 for (; it != this->m_Impl->GetC3Data()->GetHistogram()->End(); ++it)
182 if (it.GetFrequency() > 0.0)
194 for (it = startIt; it != endIt; ++it, ++i)
196 QVariant frequency = QVariant::fromValue(it.GetFrequency());
197 QVariant measurement = it.GetMeasurementVector()[0];
198 this->m_Impl->GetC3Data()->GetYDataPointer()->insert(i, frequency);
199 this->m_Impl->GetC3Data()->GetXDataPointer()->insert(i, measurement);
202 m_Impl->initializeJavaScriptChart();
211 if (m_Impl->GetPlanarFigure().IsNull())
216 if (m_Impl->GetImage().IsNull())
223 if (m_Impl->GetImage()->GetDimension() == 4)
226 timeSelector->SetInput(m_Impl->GetImage());
227 timeSelector->SetTimeNr(timeStep);
228 timeSelector->Update();
230 image = timeSelector->GetOutput();
234 image = m_Impl->GetImage();
238 image, const_cast<mitk::PlanarFigure*>(m_Impl->GetPlanarFigure().GetPointer()));
244 mitk::IntensityProfile::ConstIterator end = intensityProfile->End();
246 for (mitk::IntensityProfile::ConstIterator it = intensityProfile->Begin(); it != end; ++it)
248 m_Impl->GetC3Data()->GetYDataPointer()->push_back(it.GetMeasurementVector()[0]);
250 m_Impl->GetC3Data()->GetXDataPointer()->push_back(++i);
253 if (computeStatistics)
258 m_Impl->initializeJavaScriptChart();
263 m_Impl->GetC3Data()->ClearData();
264 m_Impl->ClearJavaScriptChart();
269 return m_Impl->GetImage();
274 m_Impl->SetImage(image);
279 return m_Impl->GetPlanarFigure();
284 m_Impl->SetPlanarFigure(planarFigure);
itk::SmartPointer< Self > Pointer
MITKIMAGESTATISTICS_EXPORT IntensityProfile::Pointer ComputeIntensityProfile(Image::Pointer image, PlanarFigure::Pointer planarFigure)
Compute intensity profile of an image for each pixel along the first PolyLine of a given planar figur...
MITKIMAGESTATISTICS_EXPORT void ComputeIntensityProfileStatistics(IntensityProfile::Pointer intensityProfile, ImageStatisticsCalculator::StatisticsContainer::Pointer stats)
Compute statistics of an intensity profile.