Commit 003d5a86 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

add same plot widgets as in SpecularDataWidgets

parent aa070ca5
......@@ -42,7 +42,8 @@ SpecularDataImportWidget::SpecularDataImportWidget(QWidget* parent)
m_ui->setupUi(this);
m_ui->linkedInstrumentGroup->hide(); // #baimport - remove from UI if not used in the future
m_ui->createNewFormatButton->hide(); // #baimport - show again when implementation is complete
// #baUserDefLoaders - remove next line when implementation is complete
m_ui->createNewFormatButton->hide();
fillLoaderCombo();
updatePropertiesEdits();
......@@ -63,11 +64,21 @@ SpecularDataImportWidget::SpecularDataImportWidget(QWidget* parent)
connect(m_ui->plotWidget, &QCustomPlot::axisClick, this,
&SpecularDataImportWidget::onAxisClick);
connect(m_ui->specularDataCanvas->customPlot(), &QCustomPlot::axisClick, this,
&SpecularDataImportWidget::onPlotAxisClicked);
m_ui->specularDataCanvas->enableDeprecatedOnMousePress(false); // we have an own handler
m_ui->plotToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
for (auto action : m_ui->specularDataCanvas->actionList())
m_ui->plotToolBar->addAction(action);
}
void SpecularDataImportWidget::setItem(SessionItem* _realDataItem)
{
SessionItemWidget::setItem(_realDataItem);
m_ui->specularDataCanvas->setItem(specularDataItem());
m_loader = dynamic_cast<AbstractDataLoader1D*>(realDataItem()->dataLoader());
ASSERT(m_loader); // only items which have a loader are allowed for this widget. Every other
......@@ -105,7 +116,7 @@ void SpecularDataImportWidget::onContextMenuRequest(const QPoint& point)
menu.exec(point);
}
void SpecularDataImportWidget::onAxisClick(QCPAxis* axis, QCPAxis::SelectablePart part,
void SpecularDataImportWidget::onAxisClick(QCPAxis* axis, QCPAxis::SelectablePart /*part*/,
QMouseEvent* event)
{
const auto setLog = [=](bool is_log_scale) {
......@@ -151,6 +162,33 @@ void SpecularDataImportWidget::onAxisClick(QCPAxis* axis, QCPAxis::SelectablePar
}
}
void SpecularDataImportWidget::onPlotAxisClicked(QCPAxis* axis, QCPAxis::SelectablePart /*part*/,
QMouseEvent* event)
{
if (event->button() == Qt::RightButton && axis->axisType() == QCPAxis::atLeft) {
QMenu menu;
QAction* lin = new QAction("Linear");
connect(lin, &QAction::triggered, [=]() { specularDataItem()->setLog(false); });
lin->setCheckable(true);
lin->setChecked(!specularDataItem()->isLog());
QAction* log = new QAction("Logarithmic");
connect(log, &QAction::triggered, [=]() { specularDataItem()->setLog(true); });
log->setCheckable(true);
log->setChecked(specularDataItem()->isLog());
auto ag = new QActionGroup(&menu);
ag->addAction(lin);
ag->addAction(log);
menu.addAction(lin);
menu.addAction(log);
menu.exec(event->globalPos());
}
}
SpecularDataItem* SpecularDataImportWidget::specularDataItem()
{
return DataItemUtils::specularDataItem(currentItem());
......
......@@ -45,7 +45,7 @@ public:
private slots:
void onContextMenuRequest(const QPoint& point);
void onAxisClick(QCPAxis* axis, QCPAxis::SelectablePart part, QMouseEvent* event);
void onPlotAxisClicked(QCPAxis* axis, QCPAxis::SelectablePart part, QMouseEvent* event);
private:
SpecularDataItem* specularDataItem();
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1039</width>
<width>861</width>
<height>580</height>
</rect>
</property>
......@@ -195,7 +195,7 @@
</widget>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab_4">
<attribute name="title">
......@@ -242,9 +242,15 @@
<string>Graph</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="StyledToolBar" name="plotToolBar" native="true"/>
</item>
<item>
<widget class="QCustomPlot" name="plotWidget" native="true"/>
</item>
<item>
<widget class="SpecularDataCanvas" name="specularDataCanvas" native="true"/>
</item>
</layout>
</widget>
</widget>
......@@ -259,6 +265,18 @@
<header>qcustomplot.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>SpecularDataCanvas</class>
<extends>QWidget</extends>
<header location="global">GUI/coregui/Views/SpecularDataWidgets/SpecularDataCanvas.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>StyledToolBar</class>
<extends>QWidget</extends>
<header>GUI/coregui/mainwindow/StyledToolBar.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment