Verified Commit c52e4c00 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

more gui tweaks

parent 4570634c
......@@ -1786,12 +1786,18 @@ void PathsBuilder::RemovePathLoops(std::vector<t_vec2>& path_vertices, bool deg,
if(dists[peak_min_idx] < min_dist_to_start)
{
min_idx = path_indices[peak_min_idx];
if(min_idx >= dists.size())
continue;
min_dist_to_start = dists[peak_min_idx];
minimum_found = true;
}
}
if(minimum_found && !DoesDirectPathCollide(path_vertices[first_pt_idx], path_vertices[min_idx], deg))
if(minimum_found &&
!DoesDirectPathCollide(
path_vertices[first_pt_idx],
path_vertices[min_idx], deg))
{
std::size_t range_start = first_pt_idx;
std::size_t range_end = min_idx;
......@@ -1801,7 +1807,11 @@ void PathsBuilder::RemovePathLoops(std::vector<t_vec2>& path_vertices, bool deg,
// a shortcut was found
if(range_start+1 < range_end)
path_vertices.erase(path_vertices.begin()+range_start+1, path_vertices.begin()+range_end);
{
path_vertices.erase(
path_vertices.begin()+range_start+1,
path_vertices.begin()+range_end);
}
}
}
......
......@@ -201,7 +201,7 @@ ConfigSpaceDlg::ConfigSpaceDlg(QWidget* parent, QSettings *sett)
// buttons
QPushButton *btnCalc = new QPushButton("Calculate Mesh", this);
QPushButton *btnSave = new QPushButton("Save Figure...", this);
QPushButton *btnClose = new QPushButton("OK", this);
QPushButton *btnClose = new QPushButton("Close", this);
// grid
auto grid = new QGridLayout(this);
......
......@@ -146,6 +146,7 @@ GeometriesBrowser::GeometriesBrowser(QWidget* parent, QSettings *sett)
// connections
connect(buttons, &QDialogButtonBox::accepted, this, &GeometriesBrowser::accept);
connect(buttons, &QDialogButtonBox::rejected, this, &GeometriesBrowser::reject);
connect(m_geotree, &QTreeWidget::customContextMenuRequested,
this, &GeometriesBrowser::ShowGeoTreeContextMenu);
......@@ -225,6 +226,9 @@ void GeometriesBrowser::GeoTreeItemChanged(QTreeWidgetItem *item, int col)
//std::cout << "renaming from " << oldid << " to " << newid << std::endl;
item->setData(col, Qt::UserRole, QString(newid.c_str()));
emit SignalRenameObject(oldid, newid);
// re-select item
m_curObject = newid;
}
......@@ -233,7 +237,7 @@ void GeometriesBrowser::GeoTreeItemChanged(QTreeWidgetItem *item, int col)
*/
void GeometriesBrowser::GeoTreeCurrentItemChanged(QTreeWidgetItem *item, QTreeWidgetItem */*previtem*/)
{
if(!item || !m_instrspace)
if(!item || !m_instrspace || !m_geosettings)
return;
std::string itemid = item->text(0).toStdString();
......@@ -245,7 +249,10 @@ void GeometriesBrowser::GeoTreeCurrentItemChanged(QTreeWidgetItem *item, QTreeWi
// ignore programmatic settings changes
m_ignoresettingschanges = true;
GeometriesBrowser* pThis = this;
BOOST_SCOPE_EXIT(pThis) { pThis->m_ignoresettingschanges = false; } BOOST_SCOPE_EXIT_END
BOOST_SCOPE_EXIT(pThis)
{
pThis->m_ignoresettingschanges = false;
} BOOST_SCOPE_EXIT_END
// get the geometry object properties and insert them in the table
......
......@@ -1032,10 +1032,10 @@ PathsTool::PathsTool(QWidget* pParent) : QMainWindow{pParent}
addDockWidget(Qt::LeftDockWidgetArea, m_tasProperties.get());
addDockWidget(Qt::LeftDockWidgetArea, m_xtalProperties.get());
addDockWidget(Qt::RightDockWidgetArea, m_xtalInfos.get());
addDockWidget(Qt::RightDockWidgetArea, m_coordProperties.get());
addDockWidget(Qt::RightDockWidgetArea, m_pathProperties.get());
addDockWidget(Qt::RightDockWidgetArea, m_camProperties.get());
addDockWidget(Qt::NoDockWidgetArea, m_xtalInfos.get());
auto* taswidget = m_tasProperties->GetWidget().get();
auto* xtalwidget = m_xtalProperties->GetWidget().get();
......@@ -1328,22 +1328,25 @@ PathsTool::PathsTool(QWidget* pParent) : QMainWindow{pParent}
// view menu
QMenu *menuView = new QMenu("View", m_menubar);
// window menu
QMenu *menuWindow = new QMenu("Window", m_menubar);
QAction *acHideAllDocks = new QAction("Hide All", menuFile);
QAction *acShowAllDocks = new QAction("Show All", menuFile);
QAction *acHideAllDocks = new QAction("Hide All Dock Widgets", menuFile);
QAction *acShowAllDocks = new QAction("Show All Dock Widgets", menuFile);
QAction *acRestoreState = new QAction("Restore Layout", menuFile);
menuView->addAction(m_tasProperties->toggleViewAction());
menuView->addAction(m_xtalProperties->toggleViewAction());
menuView->addAction(m_xtalInfos->toggleViewAction());
menuView->addAction(m_coordProperties->toggleViewAction());
menuView->addAction(m_pathProperties->toggleViewAction());
menuView->addAction(m_camProperties->toggleViewAction());
menuView->addSeparator();
menuView->addAction(acHideAllDocks);
menuView->addAction(acShowAllDocks);
//menuView->addAction(acPersp);
menuWindow->addAction(m_tasProperties->toggleViewAction());
menuWindow->addAction(m_xtalProperties->toggleViewAction());
menuWindow->addAction(m_xtalInfos->toggleViewAction());
menuWindow->addAction(m_coordProperties->toggleViewAction());
menuWindow->addAction(m_pathProperties->toggleViewAction());
menuWindow->addAction(m_camProperties->toggleViewAction());
menuWindow->addSeparator();
menuWindow->addAction(acHideAllDocks);
menuWindow->addAction(acShowAllDocks);
menuWindow->addSeparator();
menuWindow->addAction(acRestoreState);
//menuWindow->addAction(acPersp);
// connections
connect(acHideAllDocks, &QAction::triggered, [this]() -> void
......@@ -1372,6 +1375,11 @@ PathsTool::PathsTool(QWidget* pParent) : QMainWindow{pParent}
}
});
connect(acRestoreState, &QAction::triggered, [this]() -> void
{
this->restoreState(m_initial_state);
});
// geometry menu
QMenu *menuGeo = new QMenu("Geometry", m_menubar);
......@@ -1673,11 +1681,11 @@ PathsTool::PathsTool(QWidget* pParent) : QMainWindow{pParent}
// menu bar
m_menubar->addMenu(menuFile);
m_menubar->addMenu(menuView);
m_menubar->addMenu(menuGeo);
m_menubar->addMenu(menuCalc);
if(num_tools)
m_menubar->addMenu(menuTools);
m_menubar->addMenu(menuWindow);
m_menubar->addMenu(menuSettings);
m_menubar->addMenu(menuHelp);
//m_menubar->setNativeMenuBar(false);
......@@ -1772,6 +1780,9 @@ PathsTool::PathsTool(QWidget* pParent) : QMainWindow{pParent}
// --------------------------------------------------------------------
// restore window size, position, and state
// --------------------------------------------------------------------
// save initial state
m_initial_state = saveState();
if(m_sett.contains("geo"))
restoreGeometry(m_sett.value("geo").toByteArray());
else
......
......@@ -27,6 +27,7 @@
#define __PATHS_TOOL_H__
#include <QtCore/QSettings>
#include <QtCore/QByteArray>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QMenu>
......@@ -69,6 +70,7 @@ class PathsTool : public QMainWindow
{ Q_OBJECT
private:
QSettings m_sett{"takin", "taspaths"};
QByteArray m_initial_state{};
// renderer
std::shared_ptr<PathsRenderer> m_renderer
......
......@@ -142,7 +142,7 @@ XtalConfigSpaceDlg::XtalConfigSpaceDlg(QWidget* parent, QSettings *sett)
// buttons
QPushButton *btnCalc = new QPushButton("Calculate", this);
QPushButton *btnSave = new QPushButton("Save Figure...", this);
QPushButton *btnClose = new QPushButton("OK", this);
QPushButton *btnClose = new QPushButton("Close", this);
// grid
auto grid = new QGridLayout(this);
......
......@@ -48,6 +48,7 @@ CamPropertiesWidget::CamPropertiesWidget(QWidget *parent)
m_checkPerspectiveProj = new QCheckBox(this);
m_checkPerspectiveProj->setText("Perspective Projection");
m_checkPerspectiveProj->setToolTip("Choose perspective or parallel projection.");
m_checkPerspectiveProj->setChecked(true);
for(int pos=0; pos<3; ++pos)
......@@ -55,7 +56,7 @@ CamPropertiesWidget::CamPropertiesWidget(QWidget *parent)
m_spinPos[pos] = new QDoubleSpinBox(this);
m_spinPos[pos]->setMinimum(-100);
m_spinPos[pos]->setMaximum(+100);
m_spinPos[pos]->setDecimals(g_prec_gui);
m_spinPos[pos]->setDecimals(g_prec_gui/2);
m_spinPos[pos]->setSingleStep(1);
}
......@@ -94,21 +95,20 @@ CamPropertiesWidget::CamPropertiesWidget(QWidget *parent)
layoutVecs->setContentsMargins(4,4,4,4);
int y = 0;
layoutVecs->addWidget(new QLabel("Position x:", this), y, 0, 1, 1);
layoutVecs->addWidget(m_spinPos[0], y++, 1, 1, 1);
layoutVecs->addWidget(new QLabel("Position y:", this), y, 0, 1, 1);
layoutVecs->addWidget(m_spinPos[1], y++, 1, 1, 1);
layoutVecs->addWidget(new QLabel("Position z:", this), y, 0, 1, 1);
layoutVecs->addWidget(m_spinPos[2], y++, 1, 1, 1);
QFrame *separator = new QFrame(this);
separator->setFrameStyle(QFrame::HLine);
layoutVecs->addWidget(separator, y++, 0, 1, 2);
layoutVecs->addWidget(new QLabel("Rotation φ:", this), y, 0, 1, 1);
layoutVecs->addWidget(m_spinRot[0], y++, 1, 1, 1);
layoutVecs->addWidget(new QLabel("Rotation θ:", this), y, 0, 1, 1);
layoutVecs->addWidget(m_spinRot[1], y++, 1, 1, 1);
layoutVecs->addWidget(new QLabel("Position (x, y, z):", this),
y++, 0, 1, 6);
layoutVecs->addWidget(m_spinPos[0], y, 0, 1, 2);
layoutVecs->addWidget(m_spinPos[1], y, 2, 1, 2);
layoutVecs->addWidget(m_spinPos[2], y++, 4, 1, 2);
//QFrame *separator = new QFrame(this);
//separator->setFrameStyle(QFrame::HLine);
//layoutVecs->addWidget(separator, y++, 0, 1, 6);
layoutVecs->addWidget(new QLabel("Rotation (φ, θ):", this),
y++, 0, 1, 6);
layoutVecs->addWidget(m_spinRot[0], y, 0, 1, 3);
layoutVecs->addWidget(m_spinRot[1], y++, 3, 1, 3);
}
auto *grid = new QGridLayout(this);
......
......@@ -77,8 +77,8 @@ CoordPropertiesWidget::CoordPropertiesWidget(QWidget *parent)
m_spinCoords[5]->setValue(0);
m_checkKfFixed->setChecked(true);
QPushButton *btnGoto = new QPushButton("Jump to Coordinates", this);
QPushButton *btnTarget = new QPushButton("Set Coordinates as Target Angles", this);
QPushButton *btnGoto = new QPushButton("Set as Current Angles", this);
QPushButton *btnTarget = new QPushButton("Set as Target Angles", this);
btnGoto->setToolTip("Set the current instrument position to the given crystal coordinates.");
btnTarget->setToolTip("Set the given crystal coordinates as the target position for pathfinding.");
......@@ -91,7 +91,7 @@ CoordPropertiesWidget::CoordPropertiesWidget(QWidget *parent)
"Energy (E):"
};
auto *groupCoords = new QGroupBox("Crystal Coordinates", this);
auto *groupCoords = new QGroupBox(/*"Crystal Coordinates",*/ this);
{
auto *layoutStart = new QGridLayout(groupCoords);
layoutStart->setHorizontalSpacing(2);
......@@ -103,6 +103,13 @@ CoordPropertiesWidget::CoordPropertiesWidget(QWidget *parent)
{
layoutStart->addWidget(new QLabel(labels[i], this), y, 0, 1, 1);
layoutStart->addWidget(m_spinCoords[i], y++, 1, 1, 1);
if(i==2)
{
QFrame *separator = new QFrame(this);
separator->setFrameStyle(QFrame::HLine);
layoutStart->addWidget(separator, y++, 0, 1, 2);
}
}
layoutStart->addWidget(m_checkKfFixed, y++, 0, 1, 2);
......
......@@ -70,7 +70,7 @@ XtalPropertiesWidget::XtalPropertiesWidget(QWidget *parent)
m_spinPlane[i]->setMaximum(999);
m_spinPlane[i]->setDecimals(g_prec_gui/2);
m_spinPlane[i]->setValue((i==0 || i==4) ? 1 : 0);
m_spinPlane[i]->setSuffix(" rlu");
//m_spinPlane[i]->setSuffix(" rlu");
}
for(std::size_t i=1; i<m_num_lattice_elems; ++i)
......@@ -114,23 +114,29 @@ XtalPropertiesWidget::XtalPropertiesWidget(QWidget *parent)
layoutPlane->setVerticalSpacing(2);
layoutPlane->setContentsMargins(4,4,4,4);
const char* labels[] = {
"Vector 1, x:", "Vector 1, y:", "Vector 1, z:",
"Vector 2, x:", "Vector 2, y:", "Vector 2, z:"
};
const char* labels[] = { "Vector 1 (rlu):", "Vector 2 (rlu):" };
int y = 0;
for(std::size_t i=0; i<m_num_plane_elems; ++i)
{
layoutPlane->addWidget(new QLabel(labels[i], this), y, 0, 1, 1);
layoutPlane->addWidget(m_spinPlane[i], y++, 1, 1, 1);
if(i == 0 || i == 3)
{
layoutPlane->addWidget(
new QLabel(labels[i/3], this), y++, 0, 1, 3);
}
layoutPlane->addWidget(m_spinPlane[i], y, i%3, 1, 1);
if(i == 2)
{
QFrame *separator = new QFrame(this);
separator->setFrameStyle(QFrame::HLine);
layoutPlane->addWidget(separator, y++, 0, 1, 2);
//QFrame *separator = new QFrame(this);
//separator->setFrameStyle(QFrame::HLine);
//layoutPlane->addWidget(separator, y++, 0, 1, 2);
++y;
}
}
++y;
}
auto *grid = new QGridLayout(this);
......
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