Verified Commit 5e500ddf authored by Tobias WEBER's avatar Tobias WEBER
Browse files

cleanups for takin 2 release

parent a172a4e5
......@@ -16,8 +16,8 @@ endif()
set(CMAKE_CXX_STANDARD 20)
add_definitions(-std=c++20)
add_compile_options(-std=c++20)
add_compile_options(-Wall -Wextra)
# -----------------------------------------------------------------------------
......
......@@ -23,7 +23,7 @@ using t_real = t_real_cli;
/**
* real constant
*/
std::shared_ptr<Symbol> CliASTReal::Eval(CliParserContext& ctx) const
std::shared_ptr<Symbol> CliASTReal::Eval(CliParserContext&) const
{
return std::make_shared<SymbolReal>(m_val);
}
......@@ -32,7 +32,7 @@ std::shared_ptr<Symbol> CliASTReal::Eval(CliParserContext& ctx) const
/**
* string constant
*/
std::shared_ptr<Symbol> CliASTString::Eval(CliParserContext& ctx) const
std::shared_ptr<Symbol> CliASTString::Eval(CliParserContext&) const
{
return std::make_shared<SymbolString>(m_val);
}
......
......@@ -14,7 +14,7 @@
// ----------------------------------------------------------------------------
CliLexer::CliLexer(CliParserContext *ctx)
: m_pContext(ctx), yyFlexLexer()
: yyFlexLexer(), m_pContext(ctx)
{}
template<> double str_to_real(const std::string& str) { return std::stod(str); }
......
......@@ -120,7 +120,7 @@ std::shared_ptr<Symbol> func_norm(std::shared_ptr<SymbolList> sym)
/**
* typeof function
*/
static std::shared_ptr<Symbol> func_typeof(CliParserContext & ctx, std::shared_ptr<Symbol> sym)
static std::shared_ptr<Symbol> func_typeof(CliParserContext&, std::shared_ptr<Symbol> sym)
{
const std::string& ty = Symbol::get_type_name(*sym);
return std::make_shared<SymbolString>(ty);
......@@ -130,7 +130,7 @@ static std::shared_ptr<Symbol> func_typeof(CliParserContext & ctx, std::shared_p
/**
* sizeof function
*/
static std::shared_ptr<Symbol> func_sizeof(CliParserContext & ctx, std::shared_ptr<Symbol> sym)
static std::shared_ptr<Symbol> func_sizeof(CliParserContext&, std::shared_ptr<Symbol> sym)
{
if(sym->GetType() == SymbolType::ARRAY)
{ // array length
......@@ -207,12 +207,12 @@ std::shared_ptr<Symbol> func_array(CliParserContext & ctx, std::shared_ptr<Symbo
/**
* help
*/
std::shared_ptr<Symbol> func_help(CliParserContext & ctx)
std::shared_ptr<Symbol> func_help(CliParserContext&)
{
std::ostringstream ostr;
ostr << "<hr>IN20 data treatment tool version " << PROGRAM_VERSION << ".<br>\n";
ostr << "Written by Tobias Weber &lt;tweber@ill.fr&gt;, 2018-2019.<hr><br>\n";
ostr << "<hr>Takin/Scan Browser version " << PROGRAM_VERSION << ".<br>\n";
ostr << "Written by Tobias Weber &lt;tweber@ill.fr&gt;, 2018-2020.<hr><br>\n";
ostr << "Type funcs() or vars() to list available functions or variables.<br>\n";
......@@ -224,7 +224,7 @@ std::shared_ptr<Symbol> func_help(CliParserContext & ctx)
/**
* list of functions
*/
std::shared_ptr<Symbol> func_funcs(CliParserContext & ctx)
std::shared_ptr<Symbol> func_funcs(CliParserContext&)
{
std::ostringstream ostr;
......
......@@ -132,7 +132,7 @@ void CommandLineWidget::UpdateCompleter()
/**
* clicked on a completer item
*/
void CommandLineWidget::CompleterActivated(const QString &str)
void CommandLineWidget::CompleterActivated(const QString& str)
{
//std::cout << str.toStdString() << std::endl;
}
......
......@@ -613,7 +613,7 @@ Dataset Dataset::norm(std::size_t mon) const
Dataset dataset;
for(std::size_t ch=0; ch<GetNumChannels(); ++ch)
dataset.AddChannel(GetChannel(ch).norm());
dataset.AddChannel(GetChannel(ch).norm(mon));
return dataset;
}
......
......@@ -17,7 +17,7 @@ int main(int argc, char** argv)
tl2::set_locales();
QApplication app(argc, argv);
QSettings sett("tobis_stuff", "magtool");
QSettings sett("tobis_stuff", "scanbrowser");
// set GUI style
//sett.setValue("mainwnd/theme", "fusion");
......
......@@ -30,12 +30,12 @@ MainWnd::MainWnd(QSettings* pSettings)
m_pBrowser(new FileBrowser(this, pSettings)),
m_pWS(new WorkSpace(this, pSettings)),
m_pCLI(new CommandLine(this, pSettings)),
m_pCurPlot(new PlotterDock(this, pSettings))
m_pCurPlot(new Plotter(this, pSettings))
{
// the command line widget has to be accessible globally for error output
g_pCLI = m_pCLI;
this->setObjectName("magtool");
this->setObjectName("scanbrowser");
SetCurrentFile("");
LoadPlugins();
......@@ -73,7 +73,7 @@ MainWnd::MainWnd(QSettings* pSettings)
menuView->addAction(m_pBrowser->toggleViewAction());
menuView->addAction(m_pWS->toggleViewAction());
menuView->addAction(m_pCLI->toggleViewAction());
menuView->addAction(m_pCurPlot->toggleViewAction());
//menuView->addAction(m_pCurPlot->toggleViewAction());
// help
auto *acAbout = new QAction(QIcon::fromTheme("help-about"), "About...", m_pMenu);
......@@ -101,7 +101,8 @@ MainWnd::MainWnd(QSettings* pSettings)
this->addDockWidget(Qt::LeftDockWidgetArea, m_pBrowser);
this->addDockWidget(Qt::RightDockWidgetArea, m_pWS);
this->addDockWidget(Qt::BottomDockWidgetArea, m_pCLI);
this->addDockWidget(Qt::BottomDockWidgetArea, m_pCurPlot);
//this->addDockWidget(Qt::BottomDockWidgetArea, m_pCurPlot);
this->setCentralWidget(m_pCurPlot);
// ------------------------------------------------------------------------
......@@ -109,8 +110,8 @@ MainWnd::MainWnd(QSettings* pSettings)
// ------------------------------------------------------------------------
// connections
connect(m_pBrowser->GetWidget(), &FileBrowserWidget::TransferFiles, m_pWS->GetWidget(), &WorkSpaceWidget::ReceiveFiles);
connect(m_pWS->GetWidget(), &WorkSpaceWidget::PlotDataset, m_pCurPlot->GetWidget(), &Plotter::Plot);
connect(m_pBrowser->GetWidget(), &FileBrowserWidget::PlotDataset, m_pCurPlot->GetWidget(), &Plotter::Plot);
connect(m_pWS->GetWidget(), &WorkSpaceWidget::PlotDataset, m_pCurPlot, &Plotter::Plot);
connect(m_pBrowser->GetWidget(), &FileBrowserWidget::PlotDataset, m_pCurPlot, &Plotter::Plot);
connect(acNew, &QAction::triggered, this, &MainWnd::NewFile);
connect(acOpen, &QAction::triggered, this, static_cast<void(MainWnd::*)()>(&MainWnd::OpenFile));
connect(acSave, &QAction::triggered, this, static_cast<void(MainWnd::*)()>(&MainWnd::SaveFile));
......@@ -124,7 +125,7 @@ MainWnd::MainWnd(QSettings* pSettings)
m_pCLI->GetWidget()->GetParserContext().SetWorkspace(m_pWS->GetWidget()->GetWorkspace());
// connect the "workspace updated" signal from the command line parser
m_pCLI->GetWidget()->GetParserContext().GetWorkspaceUpdatedSignal().connect([this](const std::string& ident)
m_pCLI->GetWidget()->GetParserContext().GetWorkspaceUpdatedSignal().connect([this](const std::string& /*ident*/)
{
m_pWS->GetWidget()->UpdateList();
});
......@@ -217,7 +218,7 @@ void MainWnd::OpenFile()
{
QString dirLast = m_pSettings->value("mainwnd/sessiondir", "").toString();
QString filename = QFileDialog::getOpenFileName(this, "Open File", dirLast, "Magtool Files (*.mag *.MAG)");
QString filename = QFileDialog::getOpenFileName(this, "Open File", dirLast, "Scan Browser Files (*.sbr *.SBR)");
if(filename=="" || !QFile::exists(filename))
return;
......@@ -245,7 +246,7 @@ void MainWnd::SaveFileAs()
{
QString dirLast = m_pSettings->value("mainwnd/sessiondir", "").toString();
QString filename = QFileDialog::getSaveFileName(this, "Save File", dirLast, "Magtool Files (*.mag *.MAG)");
QString filename = QFileDialog::getSaveFileName(this, "Save File", dirLast, "Scan Browser Files (*.sbr *.SBR)");
if(filename=="")
return;
......@@ -259,7 +260,7 @@ void MainWnd::SaveFileAs()
*/
bool MainWnd::OpenFile(const QString &file)
{
static const std::string basename = "mag/";
static const std::string basename = "scanbrowser/";
if(file=="" || !QFile::exists(file))
return false;
......@@ -302,7 +303,7 @@ bool MainWnd::OpenFile(const QString &file)
*/
bool MainWnd::SaveFile(const QString &file)
{
static const std::string basename = "mag/";
static const std::string basename = "scanbrowser/";
if(file=="")
return false;
......@@ -389,7 +390,7 @@ void MainWnd::RebuildRecentFiles()
*/
void MainWnd::SetCurrentFile(const QString &file)
{
static const QString title("Magtool");
static const QString title("Scan Browser");
m_curFile = file;
if(m_curFile == "")
......
......@@ -76,7 +76,7 @@ private:
FileBrowser *m_pBrowser = nullptr;
WorkSpace *m_pWS = nullptr;
CommandLine *m_pCLI = nullptr;
PlotterDock *m_pCurPlot = nullptr;
Plotter *m_pCurPlot = nullptr;
QMenu *m_menuOpenRecent = nullptr;
QStringList m_recentFiles;
......
......@@ -15,20 +15,24 @@
using t_real = t_real_dat;
Plotter::Plotter(QWidget *parent, QSettings* pSettings) : QWidget(parent), m_pSettings(pSettings)
Plotter::Plotter(QWidget *parent, QSettings* pSettings)
: QWidget(parent), m_pSettings(pSettings),
m_pPlotter{std::make_shared<QCustomPlot>(this)},
m_pPlotContextMenu{new QMenu(m_pPlotter.get())}
{
auto *pGrid = new QGridLayout(this);
pGrid->setHorizontalSpacing(4);
pGrid->setVerticalSpacing(4);
pGrid->setContentsMargins(0,0,0,0);
pGrid->addWidget(m_pPlotter, 0, 0, 1, 1);
pGrid->addWidget(m_pPlotter.get(), 0, 0, 1, 1);
m_pPlotContextMenu->setTitle("Plot");
m_pPlotContextMenu->addAction("Export to Gnuplot...", this, &Plotter::SaveGpl);
m_pPlotContextMenu->addAction("Save as PDF...", this, &Plotter::SavePDF);
m_pPlotter->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_pPlotter, &QCustomPlot::customContextMenuRequested, this, &Plotter::ShowPlotContextMenu);
connect(m_pPlotter.get(), &QCustomPlot::customContextMenuRequested, this, &Plotter::ShowPlotContextMenu);
}
......@@ -101,6 +105,8 @@ void Plotter::SaveGpl()
void Plotter::Clear()
{
m_pPlotter->clearGraphs();
m_pPlotter->clearItems();
m_pPlotter->clearPlottables();
m_dataset.clear();
}
......
......@@ -24,8 +24,8 @@ class Plotter : public QWidget
private:
QSettings *m_pSettings = nullptr;
QCustomPlot *m_pPlotter = new QCustomPlot(this);
QMenu *m_pPlotContextMenu = new QMenu(m_pPlotter);
std::shared_ptr<QCustomPlot> m_pPlotter;
QMenu *m_pPlotContextMenu = nullptr;
// copy of current dataset
Dataset m_dataset;
......@@ -34,8 +34,8 @@ public:
Plotter(QWidget *parent, QSettings* = nullptr);
virtual ~Plotter();
QCustomPlot* GetPlotter() { return m_pPlotter; }
const QCustomPlot* GetPlotter() const { return m_pPlotter; }
std::shared_ptr<QCustomPlot> GetPlotter() { return m_pPlotter; }
std::shared_ptr<QCustomPlot> GetPlotter() const { return m_pPlotter; }
void Plot(const Dataset &dataset);
void Clear();
......
......@@ -108,7 +108,7 @@ void WorkSpaceWidget::ItemSelected(QListWidgetItem* pCur)
/**
* an item in the list was double-clicked
*/
void WorkSpaceWidget::ItemDoubleClicked(QListWidgetItem* pCur)
void WorkSpaceWidget::ItemDoubleClicked(QListWidgetItem*)
{
}
......@@ -223,7 +223,7 @@ void WorkSpaceWidget::ReceiveFiles(const std::vector<std::string> &files)
// insert the dataset into the workspace
std::string fileident = "sc" + filepath.baseName().toStdString();
const auto [iter, insert_ok] = m_workspace.emplace(std::make_pair(fileident, std::make_shared<SymbolDataset>(std::move(dataset))));
/*const auto [iter, insert_ok] = */m_workspace.emplace(std::make_pair(fileident, std::make_shared<SymbolDataset>(std::move(dataset))));
}
UpdateList();
......@@ -241,7 +241,7 @@ void WorkSpaceWidget::UpdateList()
// skip real or string variables
if(symdataset->GetType() != SymbolType::DATASET)
continue;
const Dataset& dataset = dynamic_cast<const SymbolDataset&>(*symdataset).GetValue();
//const Dataset& dataset = dynamic_cast<const SymbolDataset&>(*symdataset).GetValue();
QString qident(ident.c_str());
// dataset with this identifier already in list?
......
Markdown is supported
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