Skip to content

Commit 67ae093

Browse files
author
etet100
committed
Coordinates panel
1 parent 6cd706f commit 67ae093

7 files changed

Lines changed: 311 additions & 1 deletion

File tree

src/gpilot/gpilot.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ SOURCES += main.cpp\
191191
ui/forms/modals/dlgeditprogram.cpp \
192192
ui/forms/partials/main/partmainconsole.cpp \
193193
ui/forms/partials/main/partmaincontrol.cpp \
194+
ui/forms/partials/main/partmaincoordinates.cpp \
194195
ui/forms/partials/main/partmainheightmap.cpp \
195196
ui/forms/partials/main/partmainjog.cpp \
196197
ui/forms/partials/main/partmainjogparameters.cpp \
@@ -395,6 +396,7 @@ HEADERS += ui/forms/frmmain.h \
395396
ui/forms/modals/dlgeditprogram.h \
396397
ui/forms/partials/main/partmainconsole.h \
397398
ui/forms/partials/main/partmaincontrol.h \
399+
ui/forms/partials/main/partmaincoordinates.h \
398400
ui/forms/partials/main/partmainheightmap.h \
399401
ui/forms/partials/main/partmainjog.h \
400402
ui/forms/partials/main/partmainjogparameters.h \
@@ -501,6 +503,7 @@ FORMS += ui/forms/frmmain.ui \
501503
ui/forms/modals/dlgeditprogram.ui \
502504
ui/forms/partials/main/partmainconsole.ui \
503505
ui/forms/partials/main/partmaincontrol.ui \
506+
ui/forms/partials/main/partmaincoordinates.ui \
504507
ui/forms/partials/main/partmainheightmap.ui \
505508
ui/forms/partials/main/partmainjog.ui \
506509
ui/forms/partials/main/partmainjogparameters.ui \

src/gpilot/ui/forms/frmmain.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ FrmMain::FrmMain(QWidget *parent) :
100100
initializeHeightmapPanel();
101101
initializeOverridesPanel();
102102
initializeMacrosPanel();
103+
initializeCoordinatesPanel();
103104

104105
// Drag&drop placeholders
105106
ui->fraDropDevice->setVisible(false);
@@ -293,6 +294,14 @@ void FrmMain::initializeMacrosPanel()
293294
});
294295
}
295296

297+
void FrmMain::initializeCoordinatesPanel()
298+
{
299+
connect(ui->grpCoordinates, &QGroupBox::toggled, this, [this](bool checked) {
300+
updateLayouts();
301+
ui->coordinates->setVisible(checked);
302+
});
303+
}
304+
296305
void FrmMain::initializeControlPanel()
297306
{
298307
connect(ui->control, &PartMainControl::unlock, this, [this]() {

src/gpilot/ui/forms/frmmain.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ private slots:
320320
void initializeOverridesPanel();
321321
void initializeVisualizerPanel();
322322
void initializeMacrosPanel();
323+
void initializeCoordinatesPanel();
323324
void initializeVirtualSettingsPanel();
324325
void initializeDockCorners();
325326
void connectWindowTitleUpdater();

src/gpilot/ui/forms/frmmain.ui

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ QGroupBox::title {
390390
<property name="acceptDrops">
391391
<bool>true</bool>
392392
</property>
393-
<layout class="QVBoxLayout" name="verticalLayout_13" stretch="0,0,0,0,0,0">
393+
<layout class="QVBoxLayout" name="verticalLayout_13" stretch="0,0,0,0,0,0,0">
394394
<property name="sizeConstraint">
395395
<enum>QLayout::SizeConstraint::SetMinimumSize</enum>
396396
</property>
@@ -421,6 +421,18 @@ QGroupBox::title {
421421
<bool>false</bool>
422422
</property>
423423
<layout class="QVBoxLayout" name="verticalLayout_6">
424+
<property name="leftMargin">
425+
<number>7</number>
426+
</property>
427+
<property name="topMargin">
428+
<number>7</number>
429+
</property>
430+
<property name="rightMargin">
431+
<number>7</number>
432+
</property>
433+
<property name="bottomMargin">
434+
<number>7</number>
435+
</property>
424436
<item>
425437
<widget class="PartMainStateLcd" name="state" native="true">
426438
<property name="minimumSize">
@@ -434,6 +446,33 @@ QGroupBox::title {
434446
</layout>
435447
</widget>
436448
</item>
449+
<item>
450+
<widget class="QGroupBox" name="grpCoordinates">
451+
<property name="title">
452+
<string>Coordinates</string>
453+
</property>
454+
<property name="checkable">
455+
<bool>true</bool>
456+
</property>
457+
<layout class="QVBoxLayout" name="verticalLayout_4">
458+
<property name="leftMargin">
459+
<number>7</number>
460+
</property>
461+
<property name="topMargin">
462+
<number>7</number>
463+
</property>
464+
<property name="rightMargin">
465+
<number>7</number>
466+
</property>
467+
<property name="bottomMargin">
468+
<number>7</number>
469+
</property>
470+
<item>
471+
<widget class="PartMainCoordinates" name="coordinates" native="true"/>
472+
</item>
473+
</layout>
474+
</widget>
475+
</item>
437476
<item>
438477
<widget class="QFrame" name="fraDropDevice">
439478
<property name="minimumSize">
@@ -462,6 +501,18 @@ QGroupBox::title {
462501
<bool>true</bool>
463502
</property>
464503
<layout class="QVBoxLayout" name="verticalLayout" stretch="0">
504+
<property name="leftMargin">
505+
<number>7</number>
506+
</property>
507+
<property name="topMargin">
508+
<number>7</number>
509+
</property>
510+
<property name="rightMargin">
511+
<number>7</number>
512+
</property>
513+
<property name="bottomMargin">
514+
<number>7</number>
515+
</property>
465516
<item>
466517
<widget class="PartMainControl" name="control" native="true">
467518
<property name="minimumSize">
@@ -490,6 +541,18 @@ QGroupBox::title {
490541
<bool>false</bool>
491542
</property>
492543
<layout class="QVBoxLayout" name="verticalLayout_14">
544+
<property name="leftMargin">
545+
<number>7</number>
546+
</property>
547+
<property name="topMargin">
548+
<number>7</number>
549+
</property>
550+
<property name="rightMargin">
551+
<number>7</number>
552+
</property>
553+
<property name="bottomMargin">
554+
<number>7</number>
555+
</property>
493556
<item>
494557
<widget class="PartMainSpindle" name="spindle" native="true"/>
495558
</item>
@@ -508,6 +571,18 @@ QGroupBox::title {
508571
<bool>false</bool>
509572
</property>
510573
<layout class="QVBoxLayout" name="verticalLayout_11">
574+
<property name="leftMargin">
575+
<number>7</number>
576+
</property>
577+
<property name="topMargin">
578+
<number>7</number>
579+
</property>
580+
<property name="rightMargin">
581+
<number>7</number>
582+
</property>
583+
<property name="bottomMargin">
584+
<number>7</number>
585+
</property>
511586
<item>
512587
<widget class="PartMainJog" name="jog" native="true"/>
513588
</item>
@@ -526,6 +601,18 @@ QGroupBox::title {
526601
<bool>false</bool>
527602
</property>
528603
<layout class="QVBoxLayout" name="verticalLayout_11">
604+
<property name="leftMargin">
605+
<number>7</number>
606+
</property>
607+
<property name="topMargin">
608+
<number>7</number>
609+
</property>
610+
<property name="rightMargin">
611+
<number>7</number>
612+
</property>
613+
<property name="bottomMargin">
614+
<number>7</number>
615+
</property>
529616
<item>
530617
<widget class="PartMainMacros" name="macros" native="true"/>
531618
</item>
@@ -1324,6 +1411,12 @@ QGroupBox::title {
13241411
<header>ui/forms/partials/main/partmainheightmap.h</header>
13251412
<container>1</container>
13261413
</customwidget>
1414+
<customwidget>
1415+
<class>PartMainCoordinates</class>
1416+
<extends>QWidget</extends>
1417+
<header>ui/forms/partials/main/partmaincoordinates.h</header>
1418+
<container>1</container>
1419+
</customwidget>
13271420
</customwidgets>
13281421
<resources>
13291422
<include location="../resources/images.qrc"/>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// This file is a part of "G-Pilot GCode Sender" application.
2+
// Copyright 2026 BTS
3+
4+
#include "partmaincoordinates.h"
5+
#include "ui_partmaincoordinates.h"
6+
#include "core/communicator/machinecoordinatecache.h"
7+
#include <QPushButton>
8+
#include <QHeaderView>
9+
#include "styledtoolbutton.h"
10+
11+
static const QStringList CS_NAMES = {"G54", "G55", "G56", "G57", "G58", "G59"};
12+
13+
PartMainCoordinates::PartMainCoordinates(QWidget *parent)
14+
: QWidget(parent)
15+
, ui(new Ui::partMainCoordinates)
16+
{
17+
ui->setupUi(this);
18+
setupTable();
19+
}
20+
21+
PartMainCoordinates::~PartMainCoordinates()
22+
{
23+
delete ui;
24+
}
25+
26+
void PartMainCoordinates::setupTable()
27+
{
28+
ui->tableCoordinates->setRowCount(CS_NAMES.count());
29+
ui->tableCoordinates->setColumnCount(5);
30+
ui->tableCoordinates->setHorizontalHeaderLabels({"CS", "X", "Y", "Z", ""});
31+
ui->tableCoordinates->verticalHeader()->setVisible(false);
32+
ui->tableCoordinates->setSelectionMode(QAbstractItemView::NoSelection);
33+
ui->tableCoordinates->setEditTriggers(QAbstractItemView::NoEditTriggers);
34+
35+
for (int i = 0; i < CS_NAMES.count(); i++) {
36+
auto *itemCS = new QTableWidgetItem(CS_NAMES[i]);
37+
itemCS->setTextAlignment(Qt::AlignCenter);
38+
QFont boldFont = itemCS->font();
39+
boldFont.setBold(true);
40+
itemCS->setFont(boldFont);
41+
ui->tableCoordinates->setItem(i, 0, itemCS);
42+
43+
for (int col = 1; col <= 3; col++) {
44+
auto *item = new QTableWidgetItem("0.000");
45+
item->setTextAlignment(Qt::AlignCenter);
46+
ui->tableCoordinates->setItem(i, col, item);
47+
}
48+
49+
auto *btn = new StyledToolButton();
50+
btn->setIcon(QIcon(":/images/axis_zero.svg"));
51+
btn->setToolTip(tr("Select %1").arg(CS_NAMES[i]));
52+
btn->setAutoRaise(true);
53+
btn->setInvertedDartThemeIconColors(true);
54+
connect(btn, &QPushButton::clicked, this, [this, i]() {
55+
emit coordinateSystemSelected(CS_NAMES[i]);
56+
});
57+
ui->tableCoordinates->setCellWidget(i, 4, btn);
58+
}
59+
60+
auto *header = ui->tableCoordinates->horizontalHeader();
61+
header->setSectionResizeMode(QHeaderView::Stretch);
62+
header->setDefaultAlignment(Qt::AlignCenter);
63+
64+
ui->tableCoordinates->setEnabled(false);
65+
}
66+
67+
void PartMainCoordinates::updateFromCache(const MachineCoordinateCache &cache)
68+
{
69+
if (!ui->tableCoordinates->isEnabled()) {
70+
ui->tableCoordinates->setEnabled(true);
71+
}
72+
73+
for (int i = 0; i < CS_NAMES.count(); i++) {
74+
QVector3D offset = cache.coords(CS_NAMES[i]);
75+
ui->tableCoordinates->item(i, 1)->setText(QString::number(offset.x(), 'f', 3));
76+
ui->tableCoordinates->item(i, 2)->setText(QString::number(offset.y(), 'f', 3));
77+
ui->tableCoordinates->item(i, 3)->setText(QString::number(offset.z(), 'f', 3));
78+
}
79+
}
80+
81+
void PartMainCoordinates::setActiveRow(const QString &cs)
82+
{
83+
if (cs == m_activeCS) {
84+
return;
85+
}
86+
87+
m_activeCS = cs;
88+
for (int i = 0; i < CS_NAMES.count(); i++) {
89+
bool active = (CS_NAMES[i] == m_activeCS);
90+
for (int col = 0; col < 4; col++) {
91+
ui->tableCoordinates->item(i, col)->setBackground(active ? palette().highlight() : QBrush());
92+
ui->tableCoordinates->item(i, col)->setForeground(active ? palette().highlightedText() : QBrush());
93+
}
94+
}
95+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This file is a part of "G-Pilot GCode Sender" application.
2+
// Copyright 2026 BTS
3+
4+
#ifndef A53A685E_B4C0_4477_B407_51F56EA38849
5+
#define A53A685E_B4C0_4477_B407_51F56EA38849
6+
7+
#ifndef PARTMAINCOORDINATES_H
8+
#define PARTMAINCOORDINATES_H
9+
10+
#include <QWidget>
11+
#include <QVector3D>
12+
13+
class MachineCoordinateCache;
14+
15+
namespace Ui {
16+
class partMainCoordinates;
17+
}
18+
19+
class PartMainCoordinates : public QWidget
20+
{
21+
Q_OBJECT
22+
23+
public:
24+
explicit PartMainCoordinates(QWidget *parent = nullptr);
25+
~PartMainCoordinates();
26+
27+
void updateFromCache(const MachineCoordinateCache &cache);
28+
void setActiveRow(const QString &cs);
29+
30+
signals:
31+
void coordinateSystemSelected(const QString &cs);
32+
33+
private:
34+
Ui::partMainCoordinates *ui;
35+
QString m_activeCS;
36+
37+
void setupTable();
38+
};
39+
40+
#endif // PARTMAINCOORDINATES_H
41+
42+
#endif /* A53A685E_B4C0_4477_B407_51F56EA38849 */

0 commit comments

Comments
 (0)