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) ...@@ -42,7 +42,8 @@ SpecularDataImportWidget::SpecularDataImportWidget(QWidget* parent)
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->linkedInstrumentGroup->hide(); // #baimport - remove from UI if not used in the future 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(); fillLoaderCombo();
updatePropertiesEdits(); updatePropertiesEdits();
...@@ -63,11 +64,21 @@ SpecularDataImportWidget::SpecularDataImportWidget(QWidget* parent) ...@@ -63,11 +64,21 @@ SpecularDataImportWidget::SpecularDataImportWidget(QWidget* parent)
connect(m_ui->plotWidget, &QCustomPlot::axisClick, this, connect(m_ui->plotWidget, &QCustomPlot::axisClick, this,
&SpecularDataImportWidget::onAxisClick); &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) void SpecularDataImportWidget::setItem(SessionItem* _realDataItem)
{ {
SessionItemWidget::setItem(_realDataItem); SessionItemWidget::setItem(_realDataItem);
m_ui->specularDataCanvas->setItem(specularDataItem());
m_loader = dynamic_cast<AbstractDataLoader1D*>(realDataItem()->dataLoader()); m_loader = dynamic_cast<AbstractDataLoader1D*>(realDataItem()->dataLoader());
ASSERT(m_loader); // only items which have a loader are allowed for this widget. Every other 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) ...@@ -105,7 +116,7 @@ void SpecularDataImportWidget::onContextMenuRequest(const QPoint& point)
menu.exec(point); menu.exec(point);
} }
void SpecularDataImportWidget::onAxisClick(QCPAxis* axis, QCPAxis::SelectablePart part, void SpecularDataImportWidget::onAxisClick(QCPAxis* axis, QCPAxis::SelectablePart /*part*/,
QMouseEvent* event) QMouseEvent* event)
{ {
const auto setLog = [=](bool is_log_scale) { const auto setLog = [=](bool is_log_scale) {
...@@ -151,6 +162,33 @@ void SpecularDataImportWidget::onAxisClick(QCPAxis* axis, QCPAxis::SelectablePar ...@@ -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() SpecularDataItem* SpecularDataImportWidget::specularDataItem()
{ {
return DataItemUtils::specularDataItem(currentItem()); return DataItemUtils::specularDataItem(currentItem());
...@@ -359,4 +397,4 @@ void SpecularDataImportWidget::onPropertiesChanged() ...@@ -359,4 +397,4 @@ void SpecularDataImportWidget::onPropertiesChanged()
QString SpecularDataImportWidget::currentFileName() const QString SpecularDataImportWidget::currentFileName() const
{ {
return realDataItem()->nativeFileName(); return realDataItem()->nativeFileName();
} }
\ No newline at end of file
...@@ -45,7 +45,7 @@ public: ...@@ -45,7 +45,7 @@ public:
private slots: private slots:
void onContextMenuRequest(const QPoint& point); void onContextMenuRequest(const QPoint& point);
void onAxisClick(QCPAxis* axis, QCPAxis::SelectablePart part, QMouseEvent* event); void onPlotAxisClicked(QCPAxis* axis, QCPAxis::SelectablePart part, QMouseEvent* event);
private: private:
SpecularDataItem* specularDataItem(); SpecularDataItem* specularDataItem();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1039</width> <width>861</width>
<height>580</height> <height>580</height>
</rect> </rect>
</property> </property>
...@@ -195,7 +195,7 @@ ...@@ -195,7 +195,7 @@
</widget> </widget>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab_4"> <widget class="QWidget" name="tab_4">
<attribute name="title"> <attribute name="title">
...@@ -242,9 +242,15 @@ ...@@ -242,9 +242,15 @@
<string>Graph</string> <string>Graph</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="StyledToolBar" name="plotToolBar" native="true"/>
</item>
<item> <item>
<widget class="QCustomPlot" name="plotWidget" native="true"/> <widget class="QCustomPlot" name="plotWidget" native="true"/>
</item> </item>
<item>
<widget class="SpecularDataCanvas" name="specularDataCanvas" native="true"/>
</item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
...@@ -259,6 +265,18 @@ ...@@ -259,6 +265,18 @@
<header>qcustomplot.h</header> <header>qcustomplot.h</header>
<container>1</container> <container>1</container>
</customwidget> </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> </customwidgets>
<resources/> <resources/>
<connections/> <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