diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b2ac70f..bfa0300 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,475 +1,493 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2016> Author: Lays Rodrigues - lays.rodrigues@kde.org Chris Rizzitello - rizzitello@kde.org This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include "dialogs/choosefiledialog.h" #include "dialogs/profilesdialog.h" #include "mainwindow.h" #include "widgets/3dview/viewer3d.h" #include "widgets/atcoreinstancewidget.h" #include "widgets/videomonitorwidget.h" #include "widgets/welcomewidget.h" MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent) , m_currEditorView(nullptr) + , m_currInstance(0) , m_theme(getTheme()) , m_instances(new QTabWidget(this)) { initWidgets(); setupActions(); setAcceptDrops(true); connect(m_instances, &QTabWidget::tabCloseRequested, this, [this](int index) { auto tempWidget = qobject_cast(m_instances->widget(index)); if (tempWidget->isPrinting()) { if (askToClose()) { delete tempWidget; } else { return; } } else { delete tempWidget; } if (m_instances->count() == 1) { m_instances->setTabsClosable(false); m_instances->setMovable(false); } }); } void MainWindow::closeEvent(QCloseEvent *event) { if (!askToSave(m_gcodeEditor->modifiedFiles())) { event->ignore(); } bool closePrompt = false; for (int i = 0; i < m_instances->count(); i++) { AtCoreInstanceWidget *instance = qobject_cast(m_instances->widget(i)); if (instance->isPrinting()) { closePrompt = true; break; } } if (closePrompt) { if (askToClose()) { event->accept(); } else { event->ignore(); } } } void MainWindow::dragEnterEvent(QDragEnterEvent *event) { event->accept(); } void MainWindow::dropEvent(QDropEvent *event) { const QMimeData *mimeData = event->mimeData(); if (mimeData->hasUrls()) { processDropEvent(mimeData->urls()); } } void MainWindow::processDropEvent(const QList &fileList) { for (const auto &url : fileList) { //Loop thru the urls and only load ones ending our "supported" formats QString ext = url.toLocalFile().split('.').last(); if (ext.contains("gcode", Qt::CaseInsensitive) || ext.contains("gco", Qt::CaseInsensitive)) { loadFile(url); } } } void MainWindow::initWidgets() { setupLateralArea(); newAtCoreInstance(); // View: // Sidebar, Sidebar Controls, Printer Tabs. // Sidebar Controls and Printer Tabs can be resized, Sidebar can't. auto splitter = new QSplitter(); splitter->addWidget(m_lateral.m_stack); splitter->addWidget(m_instances); auto addTabBtn = new QToolButton(); addTabBtn->setIconSize(QSize(fontMetrics().lineSpacing(), fontMetrics().lineSpacing())); addTabBtn->setIcon(QIcon::fromTheme("list-add", QIcon(QString(":/%1/addTab").arg(m_theme)))); addTabBtn->setToolTip(i18n("Create new instance")); addTabBtn->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T)); connect(addTabBtn, &QToolButton::clicked, this, &MainWindow::newAtCoreInstance); m_instances->setCornerWidget(addTabBtn, Qt::TopLeftCorner); auto *centralLayout = new QHBoxLayout(); centralLayout->addWidget(m_lateral.m_toolBar); centralLayout->addWidget(splitter); auto *centralWidget = new QWidget(); centralWidget->setLayout(centralLayout); setCentralWidget(centralWidget); } void MainWindow::newAtCoreInstance() { auto newInstanceWidget = new AtCoreInstanceWidget(); QString name = QString::number(m_instances->addTab(newInstanceWidget, i18n("Connect a printer"))); newInstanceWidget->setObjectName(name); newInstanceWidget->setFileCount(m_openFiles.size()); connect(this, &MainWindow::profilesChanged, newInstanceWidget, &AtCoreInstanceWidget::updateProfileData); connect(newInstanceWidget, &AtCoreInstanceWidget::requestProfileDialog, this, [this] { std::unique_ptr pd(new ProfilesDialog); pd->exec(); emit(profilesChanged()); }); connect(newInstanceWidget, &AtCoreInstanceWidget::requestFileChooser, this, [newInstanceWidget, this] { QUrl file; switch (m_openFiles.size()) { case 0: QMessageBox::warning(this, i18n("Error"), i18n("There's no GCode File open. \n Please select a file and try again."), QMessageBox::Ok); break; case 1: file = m_openFiles.at(0); break; default: ChooseFileDialog dialog(this, m_openFiles); if (dialog.exec() == QDialog::Accepted) { file = dialog.choosenFile(); } break; } if (m_gcodeEditor->modifiedFiles().contains(file)) { int result = QMessageBox::question( this , i18n("Document Modified") , i18n("%1 \n Contains Unsaved Changes That will not be in the print.\n Would you like to Save before printing?", file.toLocalFile()) , QMessageBox::Save , QMessageBox::Cancel , QMessageBox::Ignore ); if (result == QMessageBox::Cancel) { return; } else if (result == QMessageBox::Save) { m_gcodeEditor->saveFile(file); } } newInstanceWidget->printFile(file); }); + connect(newInstanceWidget, &AtCoreInstanceWidget::bedSizeChanged, this, [this](const QSize & newSize) { + if (m_currInstance == m_instances->currentIndex()) { + updateBedSize(newSize); + } + }); + connect(newInstanceWidget, &AtCoreInstanceWidget::connectionChanged, this, &MainWindow::atCoreInstanceNameChange); if (m_instances->count() > 1) { m_instances->setTabsClosable(true); m_instances->setMovable(true); m_instances->setCurrentIndex(m_instances->count() - 1); } } // Move to LateralArea. void MainWindow::setupLateralArea() { m_lateral.m_toolBar = new QWidget(); m_lateral.m_stack = new QStackedWidget(); auto buttonLayout = new QVBoxLayout(); auto setupButton = [this, buttonLayout](const QString & key, const QString & text, const QIcon & icon, QWidget * w) { auto *btn = new QPushButton(m_lateral.m_toolBar); btn->setToolTip(text); btn->setAutoExclusive(true); btn->setCheckable(true); //3d view is on top set it checked so users see its selected. btn->setChecked(key == QStringLiteral("welcome")); btn->setIcon(icon); //Set an iconSize based on the DPI. //96 was considered to be the "standard" DPI for years. //Hi-dpi monitors have a higher DPI //Tiny or old screen could have a lower DPI. //Start our iconSize at 16 so with a DPI less then 96 we get a sane iconsize. int iconSize = 16 + ((logicalDpiX() / 96) * 16); btn->setIconSize(QSize(iconSize, iconSize)); btn->setFixedSize(btn->iconSize()); btn->setFlat(true); m_lateral.m_stack->addWidget(w); m_lateral.m_map[key] = {btn, w}; buttonLayout->addWidget(btn); connect(btn, &QPushButton::clicked, this, [this, w, btn] { if (m_lateral.m_stack->currentWidget() == w) { m_lateral.m_stack->setHidden(m_lateral.m_stack->isVisible()); if (m_lateral.m_stack->isHidden()) { btn->setCheckable(false); btn->setCheckable(true); } } else { m_lateral.m_stack->setHidden(false); m_lateral.m_stack->setCurrentWidget(w); } toggleGCodeActions(); }); }; m_gcodeEditor = new GCodeEditorWidget(this); connect(m_gcodeEditor, &GCodeEditorWidget::updateClientFactory, this, &MainWindow::updateClientFactory); connect(m_gcodeEditor, &GCodeEditorWidget::droppedUrls, this, &MainWindow::processDropEvent); connect(m_gcodeEditor, &GCodeEditorWidget::fileClosed, this, [this](const QUrl & file) { m_openFiles.removeAll(file); }); auto *viewer3D = new Viewer3D(this); connect(viewer3D, &Viewer3D::droppedUrls, this, &MainWindow::processDropEvent); + //Connect for bed size + connect(m_instances, &QTabWidget::currentChanged, this, [this](int index) { + m_currInstance = index; + auto tempWidget = qobject_cast(m_instances->widget(index)); + updateBedSize(tempWidget->bedSize()); + }); connect(m_gcodeEditor, &GCodeEditorWidget::currentFileChanged, this, [viewer3D](const QUrl & url) { viewer3D->drawModel(url.toLocalFile()); }); setupButton("welcome", i18n("&Welcome"), QIcon::fromTheme("go-home", QIcon(QString(":/%1/home").arg(m_theme))), new WelcomeWidget(this)); setupButton("3d", i18n("&3D"), QIcon::fromTheme("draw-cuboid", QIcon(QString(":/%1/3d").arg(m_theme))), viewer3D); setupButton("gcode", i18n("&GCode"), QIcon::fromTheme("accessories-text-editor", QIcon(":/icon/edit")), m_gcodeEditor); setupButton("video", i18n("&Video"), QIcon::fromTheme("camera-web", QIcon(":/icon/video")), new VideoMonitorWidget(this)); buttonLayout->addStretch(); m_lateral.m_toolBar->setLayout(buttonLayout); } void MainWindow::setupActions() { // Actions for the Toolbar QAction *action; action = actionCollection()->addAction(QStringLiteral("open")); action->setIcon(QIcon::fromTheme("document-open", QIcon(QString(":/%1/open").arg(m_theme)))); action->setText(i18n("&Open")); actionCollection()->setDefaultShortcut(action, QKeySequence::Open); connect(action, &QAction::triggered, this, &MainWindow::openActionTriggered); action = actionCollection()->addAction(QStringLiteral("new_instance")); action->setIcon(QIcon::fromTheme("list-add", QIcon(QString(":/%1/addTab").arg(m_theme)))); action->setText(i18n("&New Connection")); actionCollection()->setDefaultShortcut(action, QKeySequence::AddTab); connect(action, &QAction::triggered, this, &MainWindow::newAtCoreInstance); action = actionCollection()->addAction(QStringLiteral("profiles")); action->setIcon(QIcon::fromTheme("document-properties", QIcon(QString(":/%1/configure").arg(m_theme)))); action->setText(i18n("&Profiles")); connect(action, &QAction::triggered, this, [this] { std::unique_ptr pd(new ProfilesDialog); pd->exec(); emit(profilesChanged()); }); action = actionCollection()->addAction(QStringLiteral("quit")); action->setIcon(QIcon::fromTheme("application-exit", QIcon(":/icon/exit"))); action->setText(i18n("&Quit")); actionCollection()->setDefaultShortcut(action, QKeySequence::Quit); connect(action, &QAction::triggered, this, &MainWindow::close); setupGUI(Default, "atelierui"); } void MainWindow::openActionTriggered() { QList fileList = QFileDialog::getOpenFileUrls( this , i18n("Open GCode") , QUrl::fromLocalFile(QDir::homePath()) , i18n("GCode(*.gco *.gcode);;All Files(*.*)") ); for (const auto &url : fileList) { loadFile(url); } } void MainWindow::loadFile(const QUrl &fileName) { if (!fileName.isEmpty()) { m_lateral.get("gcode")->loadFile(fileName); m_lateral.get("3d")->drawModel(fileName.toLocalFile()); // Make 3dview focused when opening a file if (m_openFiles.isEmpty() && m_lateral.m_stack->currentWidget() == m_lateral.get("welcome")) { m_lateral.getButton("3d")->setChecked(true); m_lateral.m_stack->setCurrentWidget(m_lateral.get("3d")); } const int tabs = m_instances->count(); if (!m_openFiles.contains(fileName)) { m_openFiles.append(fileName); } for (int i = 0; i < tabs; ++i) { auto instance = qobject_cast(m_instances->widget(i)); instance->setFileCount(m_openFiles.size()); } } } void MainWindow::atCoreInstanceNameChange(const QString &name) { m_instances->setTabText(sender()->objectName().toInt(), name); } QString MainWindow::getTheme() { return palette().text().color().value() >= QColor(Qt::lightGray).value() ? \ QString("dark") : QString("light"); } bool MainWindow::askToClose() { bool rtn = false; int result = QMessageBox::question( this , i18n("Printing") , i18n("Currently printing! \nAre you sure you want to close?") , QMessageBox::Close , QMessageBox::Cancel ); switch (result) { case QMessageBox::Close: rtn = true; break; default: break; } return rtn; } void MainWindow::toggleGCodeActions() { if (m_lateral.m_stack->currentWidget() == m_lateral.m_map["gcode"].second && m_lateral.m_stack->isVisible()) { if (m_currEditorView) { guiFactory()->addClient(m_currEditorView); } } else { guiFactory()->removeClient(m_currEditorView); } } void MainWindow::updateClientFactory(KTextEditor::View *view) { if (m_lateral.m_stack->currentWidget() == m_lateral.m_map["gcode"].second) { if (m_currEditorView) { guiFactory()->removeClient(m_currEditorView); } if (view) { guiFactory()->addClient(view); } } m_currEditorView = view; } bool MainWindow::askToSave(const QVector &fileList) { if (fileList.isEmpty()) { return true; } QSize iconSize = QSize(fontMetrics().lineSpacing(), fontMetrics().lineSpacing()); auto dialog = new QDialog(); const int padding = 30; auto listWidget = new QListWidget(); listWidget->setMinimumWidth(fontMetrics().height() / 2 * padding); for (const auto &url : fileList) { listWidget->addItem(url.toLocalFile() + " [*]"); } auto hLayout = new QHBoxLayout(); auto saveBtn = new QPushButton(QIcon::fromTheme("document-save", QIcon(QStringLiteral(":/%1/save").arg(m_theme))), i18n("Save Selected")); saveBtn->setIconSize(iconSize); connect(saveBtn, &QPushButton::clicked, this, [this, &listWidget, &fileList, &dialog] { if (!m_gcodeEditor->saveFile(fileList.at(listWidget->currentRow()))) { QMessageBox::information(this, i18n("Save Failed"), i18n("Failed to save file: %1").arg(fileList.at(listWidget->currentRow()).toLocalFile())); } else { QString txt = listWidget->item(listWidget->currentRow())->text(); txt.remove(" [*]"); listWidget->item(listWidget->currentRow())->setText(txt); for (int i = 0; i < listWidget->count(); i++) { QString string = listWidget->item(i)->text(); if (string.endsWith(" [*]")) { return; } } dialog->accept(); } }); hLayout->addWidget(saveBtn); auto saveAllBtn = new QPushButton(QIcon::fromTheme("document-save-all", QIcon(QStringLiteral(":/%1/saveAll").arg(m_theme))), i18n("Save All")); saveAllBtn->setIconSize(iconSize); connect(saveAllBtn, &QPushButton::clicked, this, [this, &listWidget, &fileList, &dialog] { for (int i = 0; i < listWidget->count(); i++) { if (!m_gcodeEditor->saveFile(fileList.at(i))) { QMessageBox::information(this, i18n("Save Failed"), i18n("Failed to save file: %1").arg(fileList.at(i).toLocalFile())); dialog->reject(); } else { QString txt = listWidget->item(listWidget->currentRow())->text(); txt.remove(" [*]"); listWidget->item(listWidget->currentRow())->setText(txt); } } dialog->accept(); }); hLayout->addWidget(saveAllBtn); auto cancelBtn = new QPushButton(QIcon::fromTheme("dialog-cancel", QIcon(QStringLiteral(":/%1/cancel").arg(m_theme))), i18n("Cancel")); cancelBtn->setIconSize(iconSize); connect(cancelBtn, &QPushButton::clicked, this, [&dialog] { dialog->reject(); }); hLayout->addWidget(cancelBtn); auto ignoreBtn = new QPushButton(QIcon::fromTheme("window-close", QIcon(QStringLiteral(":/icon/close"))), i18n("Ignore")); ignoreBtn->setIconSize(iconSize); connect(ignoreBtn, &QPushButton::clicked, this, [&dialog] { dialog->accept(); }); hLayout->addWidget(ignoreBtn); auto layout = new QVBoxLayout; auto label = new QLabel(i18n("Files with Unsaved Changes.")); layout->addWidget(label); layout->addWidget(listWidget); layout->addItem(hLayout); dialog->setLayout(layout); return dialog->exec(); } + +void MainWindow::updateBedSize(const QSize &newSize) +{ + m_lateral.get("3d")->setBedSize(newSize); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index b142f41..54124e4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -1,85 +1,87 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2016> Author: Lays Rodrigues - lays.rodrigues@kde.org Chris Rizzitello - rizzitello@kde.org This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #pragma once #include #include #include #include #include #include #include #include "widgets/gcodeeditorwidget.h" struct LateralArea { // Area with the the lateral buttons that will open the views. // Kind like the KDevelop stuff but way simpler. using Btn2Widget = QPair; using WidgetMap = QMap; QWidget *m_toolBar; QStackedWidget *m_stack; WidgetMap m_map; template T *get(const QString &s) { return qobject_cast(m_map[s].second); } template T *getButton(const QString &s) { return qobject_cast(m_map[s].first); } }; class MainWindow : public KXmlGuiWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = nullptr); protected: void closeEvent(QCloseEvent *event); void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); private: GCodeEditorWidget *m_gcodeEditor; KTextEditor::View *m_currEditorView; + int m_currInstance; LateralArea m_lateral; QList m_openFiles; QString m_theme; QTabWidget *m_instances; bool askToClose(); bool askToSave(const QVector &fileList); void atCoreInstanceNameChange(const QString &name); QString getTheme(); void initWidgets(); void loadFile(const QUrl &fileName); void newAtCoreInstance(); void openActionTriggered(); void processDropEvent(const QList &fileList); void setupActions(); void setupLateralArea(); void toggleGCodeActions(); + void updateBedSize(const QSize &newSize); void updateClientFactory(KTextEditor::View *view); signals: void extruderCountChanged(int count); void profilesChanged(); }; diff --git a/src/widgets/3dview/viewer3d.cpp b/src/widgets/3dview/viewer3d.cpp index 85c1134..4d12972 100644 --- a/src/widgets/3dview/viewer3d.cpp +++ b/src/widgets/3dview/viewer3d.cpp @@ -1,80 +1,93 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017> Author: Patrick José Pereira - patrickjp@kde.org Chris Rizzitello - rizzitello@kde.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include "axisgnomonentity.h" #include "cameracontroller.h" #include "gridmesh.h" #include "viewer3d.h" #include "linemesh.h" Viewer3D::Viewer3D(QWidget *parent) : QWidget(parent) , _lineMesh(new LineMesh) { Q_INIT_RESOURCE(viewer3d); qmlRegisterType("Atelier", 1, 0, "AxisGnomonEntity"); qmlRegisterType("Atelier", 1, 0, "CameraController"); qmlRegisterType("Atelier", 1, 0, "GridMesh"); qmlRegisterType("Atelier", 1, 0, "LineMesh"); _view = new QQuickView(&_engine, nullptr); auto format = QSurfaceFormat(); format.setVersion(3, 1); format.setProfile(QSurfaceFormat::CoreProfile); _view->setFormat(format); _view->setResizeMode(QQuickView::SizeRootObjectToView); _view->setSource(QUrl(QStringLiteral("qrc:/viewer3d.qml"))); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addWidget(QWidget::createWindowContainer(_view)); QObject *item = _view->rootObject(); //Connect the drop pass from the QML part. connect(item, SIGNAL(droppedUrls(QVariant)), this, SLOT(dropCatch(QVariant))); this->setLayout(mainLayout); } Viewer3D::~Viewer3D() { } void Viewer3D::dropCatch(const QVariant &var) { emit droppedUrls(var.value >()); } void Viewer3D::drawModel(QString file) { QObject *object = _view->rootObject(); QObject *fileName = object->findChild(QStringLiteral("fileName")); fileName->setProperty("text", QVariant(file)); } + +void Viewer3D::setBedSize(const QSize &newBedSize) +{ + if (newBedSize != _bedSize) { + _bedSize = newBedSize; + emit bedSizeChanged(_bedSize); + } +} + +QSize Viewer3D::bedSize() +{ + return _bedSize; +} diff --git a/src/widgets/3dview/viewer3d.h b/src/widgets/3dview/viewer3d.h index 10376f5..2b68f13 100644 --- a/src/widgets/3dview/viewer3d.h +++ b/src/widgets/3dview/viewer3d.h @@ -1,50 +1,55 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017> Author: Patrick José Pereira - patrickjp@kde.org Chris Rizzitello - rizzitello@kde.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of version 3 of the license. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #pragma once #include #include #include class LineMesh; class QString; class Viewer3D : public QWidget { Q_OBJECT + Q_PROPERTY(QSize bedSize READ bedSize WRITE setBedSize NOTIFY bedSizeChanged) public slots: void dropCatch(const QVariant &var); + void setBedSize(const QSize &newBedSize); public: explicit Viewer3D(QWidget *parent = nullptr); ~Viewer3D() override; + QSize bedSize(); void drawModel(QString file); private: LineMesh *_lineMesh; QQmlApplicationEngine _engine; QQuickView *_view; + QSize _bedSize = QSize(50, 50); signals: void droppedUrls(QList fileList); + void bedSizeChanged(QSize bedSize); }; diff --git a/src/widgets/atcoreinstancewidget.cpp b/src/widgets/atcoreinstancewidget.cpp index 3ef2f48..9acbafb 100644 --- a/src/widgets/atcoreinstancewidget.cpp +++ b/src/widgets/atcoreinstancewidget.cpp @@ -1,628 +1,651 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017> Author: Lays Rodrigues - lays.rodrigues@kde.org Chris Rizzitello - rizzitello@kde.org This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include "atcoreinstancewidget.h" AtCoreInstanceWidget::AtCoreInstanceWidget(QWidget *parent): QWidget(parent) , m_fileCount(0) , m_printAction(nullptr) , m_stopAction(nullptr) , m_toolBar(nullptr) + , m_bedSize(200, 200) { m_theme = palette().text().color().value() >= QColor(Qt::lightGray).value() ? QString("dark") : QString("light") ; m_iconSize = QSize(fontMetrics().lineSpacing(), fontMetrics().lineSpacing()); QHBoxLayout *HLayout = new QHBoxLayout; m_bedExtWidget = new BedExtruderWidget; HLayout->addWidget(m_bedExtWidget); m_movementWidget = new MovementWidget(false); m_movementWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); HLayout->addWidget(m_movementWidget); QVBoxLayout *VLayout = new QVBoxLayout; VLayout->addLayout(HLayout); m_plotWidget = new PlotWidget(); VLayout->addWidget(m_plotWidget, 80); QWidget *controlTab = new QWidget(); controlTab->setLayout(VLayout); //AdvancedTab VLayout = new QVBoxLayout; m_printWidget = new PrintWidget(false); VLayout->addWidget(m_printWidget); m_commandWidget = new CommandWidget; VLayout->addWidget(m_commandWidget); m_logWidget = new LogWidget(new QTemporaryFile(QDir::tempPath() + QStringLiteral("/Atelier_"))); VLayout->addWidget(m_logWidget); m_advancedTab = new QWidget; m_advancedTab->setLayout(VLayout); m_sdWidget = new SdWidget; VLayout = new QVBoxLayout(); buildToolbar(); buildConnectionToolbar(); HLayout = new QHBoxLayout; HLayout->addWidget(m_toolBar); HLayout->addWidget(m_connectToolBar); HLayout->addWidget(m_connectButton); VLayout->addLayout(HLayout); m_toolBar->setHidden(true); m_tabWidget = new QTabWidget; m_tabWidget->addTab(controlTab, i18n("Controls")); m_tabWidget->addTab(m_advancedTab, i18n("Advanced")); m_tabWidget->addTab(m_sdWidget, i18n("Sd Card")); VLayout->addWidget(m_tabWidget); m_statusWidget = new StatusWidget(false); m_statusWidget->showPrintArea(false); VLayout->addWidget(m_statusWidget); setLayout(VLayout); enableControls(false); updateProfileData(); initConnectsToAtCore(); } AtCoreInstanceWidget::~AtCoreInstanceWidget() { m_core.closeConnection(); } void AtCoreInstanceWidget::buildToolbar() { m_toolBar = new QToolBar(); m_toolBar->setIconSize(m_iconSize); m_toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); auto lb = new QLabel; QIcon icon = QIcon::fromTheme("go-home", QIcon(QString(":/%1/home").arg(m_theme))); lb->setPixmap(icon.pixmap(m_iconSize)); m_toolBar->addWidget(lb); lb = new QLabel(i18n("Home:")); m_toolBar->addWidget(lb); auto homeAll = new QAction(i18n("All")); connect(homeAll, &QAction::triggered, this, [this] { m_core.home(); }); m_toolBar->addAction(homeAll); for (auto homes : std::map {{"X", AtCore::X}, {"Y", AtCore::Y}, {"Z", AtCore::Z}}) { auto home = new QAction(homes.first); connect(home, &QAction::triggered, this, [this, homes] { m_core.home(uchar(homes.second)); }); m_toolBar->addAction(home); } m_toolBar->addSeparator(); m_printAction = new QAction(QIcon::fromTheme("media-playback-start", style()->standardIcon(QStyle::SP_MediaPlay)), i18n("Print")); connect(m_printAction, &QAction::triggered, this, [this] { if (m_core.state() == AtCore::BUSY) { m_logWidget->appendLog(i18n("Pause Print")); pausePrint(); return; } if (m_core.state() == AtCore::IDLE) { print(); } else if (m_core.state() == AtCore::PAUSE) { m_logWidget->appendLog(i18n("Resume Print")); m_core.resume(); } }); m_toolBar->addAction(m_printAction); m_stopAction = new QAction(QIcon::fromTheme("media-playback-stop", QIcon(QString(":/%1/stop").arg(m_theme))), i18n("Stop")); connect(m_stopAction, &QAction::triggered, this, &AtCoreInstanceWidget::stopPrint); connect(m_stopAction, &QAction::triggered, this, [this] { m_printAction->setText(i18n("Print")); m_printAction->setIcon(QIcon::fromTheme("media-playback-start", QIcon(QString(":/%1/start").arg(m_theme)))); }); m_toolBar->addAction(m_stopAction); auto disableMotorsAction = new QAction(style()->standardIcon(QStyle::SP_MediaStop), i18n("Disable Motors")); connect(disableMotorsAction, &QAction::triggered, this, &AtCoreInstanceWidget::disableMotors); m_toolBar->addAction(disableMotorsAction); togglePrintButtons(m_fileCount); } void AtCoreInstanceWidget::buildConnectionToolbar() { m_connectToolBar = new QToolBar(); m_comboPort = new QComboBox; m_comboPort->setEditable(true); QLabel *deviceLabel = new QLabel(i18n("Device")); QHBoxLayout *deviceLayout = new QHBoxLayout; deviceLayout->addWidget(deviceLabel); deviceLayout->addWidget(m_comboPort, 100); m_comboProfile = new QComboBox; m_comboProfile->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); QHBoxLayout *profileLayout = new QHBoxLayout; QLabel *profileLabel = new QLabel(i18n("Profile")); profileLayout->addWidget(profileLabel); profileLayout->addWidget(m_comboProfile, 100); QHBoxLayout *connectLayout = new QHBoxLayout; connectLayout->addLayout(deviceLayout, 50); connectLayout->addLayout(profileLayout, 50); m_connectWidget = new QWidget(); m_connectWidget->setLayout(connectLayout); m_connectToolBar->addWidget(m_connectWidget); m_connectButton = new QPushButton(QIcon::fromTheme("network-connect", QIcon(QString(":/%1/connect").arg(m_theme))), i18n("Connect")); m_connectButton->setIconSize(m_iconSize); m_connectButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); connect(this, &AtCoreInstanceWidget::disableDisconnect, m_connectButton, &QPushButton::setDisabled); connect(m_connectButton, &QPushButton::clicked, this, &AtCoreInstanceWidget::connectButtonClicked); } void AtCoreInstanceWidget::connectButtonClicked() { if (m_core.state() == AtCore::DISCONNECTED) { if (m_comboProfile->currentText().isEmpty()) { QMessageBox::information( this , i18n("No Profiles!") , i18n("Connecting Requires creating a profile for your printer. Create a profile in the next dialog then try again.") ); emit(requestProfileDialog()); return; } if (m_comboPort->currentText().isEmpty()) { QMessageBox::critical( this , i18n("Error") , i18n("Please, connect a serial device to continue!") ); return; } //Get profile data before connecting. m_profileData = readProfile(); //then connect if (m_core.initSerial(m_comboPort->currentText(), m_profileData["bps"].toInt())) { QString fw = m_profileData["firmware"].toString(); m_logWidget->appendLog(i18n("Firmware: %1", fw)); if (fw != QString("Auto-Detect")) { m_core.loadFirmwarePlugin(fw); } emit(connectionChanged(m_profileData["name"].toString())); m_profileData["heatedBed"].toBool() ? m_bedExtWidget->setBedMaxTemperature(m_profileData["bedTemp"].toInt()) : m_bedExtWidget->setBedThermoHidden(true); m_bedExtWidget->setExtruderMaxTemperature(m_profileData["hotendTemp"].toInt()); //AddFan Support to profile m_printWidget->updateFanCount(2); + //Adjust bed size + QSize newSize; + if (m_profileData["isCartesian"].toBool()) { + newSize = QSize(m_profileData["dimensionX"].toInt(), m_profileData["dimensionY"].toInt()); + } else { + newSize = QSize(m_profileData["radius"].toInt(), 0); + } + if (newSize != m_bedSize) { + m_bedSize = newSize; + emit bedSizeChanged(m_bedSize); + } } } else { m_core.closeConnection(); emit(connectionChanged(i18n("Connect a Printer"))); } } void AtCoreInstanceWidget::initConnectsToAtCore() { //connect log to atcoreMessages connect(&m_core, &AtCore::atcoreMessage, m_logWidget, &LogWidget::appendLog); m_core.setSerialTimerInterval(100); // Handle device changes connect(&m_core, &AtCore::portsChanged, this, &AtCoreInstanceWidget::updateSerialPort); // Handle AtCore status change connect(&m_core, &AtCore::stateChanged, this, &AtCoreInstanceWidget::handlePrinterStatusChanged); // If the number of extruders from the printer change, we need to update the radiobuttons on the widget connect(this, &AtCoreInstanceWidget::extruderCountChanged, m_bedExtWidget, &BedExtruderWidget::setExtruderCount); // Bed and Extruder temperatures management connect(m_bedExtWidget, &BedExtruderWidget::bedTemperatureChanged, &m_core, &AtCore::setBedTemp); connect(m_bedExtWidget, &BedExtruderWidget::extTemperatureChanged, &m_core, &AtCore::setExtruderTemp); //command Widget connect(m_commandWidget, &CommandWidget::commandPressed, this, [this](const QString & command) { m_logWidget->appendLog(i18n("Push: %1", command)); m_core.pushCommand(command); }); connect(m_commandWidget, &CommandWidget::messagePressed, [this](const QString & message) { m_logWidget->appendLog(i18n("Display: %1", message)); m_core.showMessage(message); }); // Fan, Flow and Speed management connect(m_printWidget, &PrintWidget::fanSpeedChanged, &m_core, &AtCore::setFanSpeed); connect(m_printWidget, &PrintWidget::flowRateChanged, &m_core, &AtCore::setFlowRate); connect(m_printWidget, &PrintWidget::printSpeedChanged, &m_core, &AtCore::setPrinterSpeed); //Movement Widget connect(m_movementWidget, &MovementWidget::absoluteMove, this, [this](const QLatin1Char & axis, const double value) { m_logWidget->appendLog(GCode::description(GCode::G1)); m_core.move(axis, value); }); connect(m_movementWidget, &MovementWidget::unitsChanged, this, [this](int units) { auto selection = static_cast(units); m_core.setUnits(selection); }); connect(m_movementWidget, &MovementWidget::relativeMove, this, [this](const QLatin1Char & axis, const double value) { m_logWidget->appendLog(i18n("Relative Move: %1, %2", axis, QString::number(value))); m_core.setRelativePosition(); m_core.move(axis, value); m_core.setAbsolutePosition(); }); //Sd Card Stuff connect(&m_core, &AtCore::sdCardFileListChanged, m_sdWidget, &SdWidget::updateFilelist); connect(m_sdWidget, &SdWidget::requestSdList, &m_core, &AtCore::sdFileList); connect(&m_core, &AtCore::sdMountChanged, m_statusWidget, &StatusWidget::setSD); connect(m_sdWidget, &SdWidget::printSdFile, this, [this](const QString & fileName) { if (fileName.isEmpty()) { QMessageBox::information( this , i18n("Print Error") , i18n("You must Select a file from the list") ); } else { m_core.print(fileName, true); togglePrintButtons(true); } }); connect(m_sdWidget, &SdWidget::deleteSdFile, this, [this](const QString & fileName) { if (fileName.isEmpty()) { QMessageBox::information( this , i18n("Delete Error") , i18n("You must Select a file from the list") ); } else { m_core.sdDelete(fileName); } }); } void AtCoreInstanceWidget::printFile(const QUrl &fileName) { if (fileName.isEmpty()) { QMessageBox::critical( this , i18n("Filename Empty") , i18n("No filename sent from calling method, please check and try again.") ); return; } else if (!QFileInfo(fileName.toLocalFile()).isReadable()) { QMessageBox::critical( this , i18n("File not found") , i18n("%1 \nIs not readable, please check and try again.", fileName.toLocalFile()) ); return; } if (m_core.state() == AtCore::IDLE) { m_logWidget->appendLog(i18n("Printing:%1", fileName.toLocalFile())); m_core.print(fileName.toLocalFile()); } } void AtCoreInstanceWidget::print() { emit(requestFileChooser()); } void AtCoreInstanceWidget::pausePrint() { if (m_core.state() == AtCore::BUSY) { m_core.pause(m_profileData["postPause"].toString()); } else if (m_core.state() == AtCore::PAUSE) { m_core.resume(); } } void AtCoreInstanceWidget::stopPrint() { m_core.stop(); } void AtCoreInstanceWidget::disableMotors() { m_core.disableMotors(0); } void AtCoreInstanceWidget::handlePrinterStatusChanged(AtCore::STATES newState) { static QString stateString; switch (newState) { case AtCore::CONNECTING: { m_core.setSerialTimerInterval(0); m_connectButton->setText(i18n("Disconnect")); m_connectButton->setIcon(QIcon::fromTheme("network-disconnect", QIcon(QString(":/%1/disconnect").arg(m_theme)))); m_connectToolBar->setHidden(true); m_toolBar->setHidden(false); stateString = i18n("Connecting..."); m_logWidget->appendLog(i18n("Attempting to Connect")); connect(&m_core, &AtCore::receivedMessage, m_logWidget, &LogWidget::appendRLog); connect(&m_core, &AtCore::pushedCommand, m_logWidget, &LogWidget::appendSLog); } break; case AtCore::IDLE: { stateString = i18n("Connected to %1", m_core.connectedPort()); emit extruderCountChanged(m_core.extruderCount()); m_logWidget->appendLog(stateString); emit disableDisconnect(false); enableControls(true); connectExtruderTemperatureData(true); if (m_profileData["heatedBed"].toBool()) { connectBedTemperatureData(true); } } break; case AtCore::DISCONNECTED: { stateString = i18n("Not Connected"); disconnect(&m_core, &AtCore::receivedMessage, m_logWidget, &LogWidget::appendRLog); disconnect(&m_core, &AtCore::pushedCommand, m_logWidget, &LogWidget::appendSLog); m_logWidget->appendLog(i18n("Serial disconnected")); m_core.setSerialTimerInterval(100); m_connectButton->setText(i18n("Connect")); m_connectButton->setIcon(QIcon::fromTheme("network-connect", QIcon(QString(":/%1/connect").arg(m_theme)))); m_connectToolBar->setHidden(false); m_toolBar->setHidden(true); enableControls(false); connectExtruderTemperatureData(false); if (m_profileData["heatedBed"].toBool()) { connectBedTemperatureData(false); } } break; case AtCore::STARTPRINT: { stateString = i18n("Starting Print"); m_statusWidget->showPrintArea(true); connect(&m_core, &AtCore::printProgressChanged, m_statusWidget, &StatusWidget::updatePrintProgress); } break; case AtCore::FINISHEDPRINT: { stateString = i18n("Finished Print"); m_statusWidget->showPrintArea(false); disconnect(&m_core, &AtCore::printProgressChanged, m_statusWidget, &StatusWidget::updatePrintProgress); m_printAction->setText(i18n("Print")); m_printAction->setIcon(QIcon::fromTheme("media-playback-start", QIcon(QString(":/%1/start").arg(m_theme)))); m_logWidget->appendLog(i18n("Finished Print Job")); } break; case AtCore::BUSY: { stateString = i18n("Printing"); emit disableDisconnect(true); m_printAction->setText(i18n("Pause")); m_printAction->setIcon(QIcon::fromTheme("media-playback-pause", QIcon(QString(":/%1/pause").arg(m_theme)))); } break; case AtCore::PAUSE: { stateString = i18n("Paused"); m_printAction->setText(i18n("Resume")); m_printAction->setIcon(QIcon::fromTheme("media-playback-start", QIcon(QString(":/%1/start").arg(m_theme)))); } break; case AtCore::STOP: { stateString = i18n("Stoping Print"); m_logWidget->appendLog(stateString); } break; case AtCore::ERRORSTATE: { stateString = i18n("Error"); } break; default: m_logWidget->appendLog(i18n("Unknown AtCore State, %1", newState)); qWarning("AtCore State not Recognized."); break; } m_statusWidget->setState(stateString); } void AtCoreInstanceWidget::checkTemperature(uint sensorType, uint number, float temp) { static QString msg; switch (sensorType) { case 0x00: // bed msg = QString::fromLatin1("Bed Temperature "); break; case 0x01: // bed target msg = QString::fromLatin1("Bed Target Temperature "); break; case 0x02: // extruder msg = QString::fromLatin1("Extruder Temperature "); break; case 0x03: // extruder target msg = QString::fromLatin1("Extruder Target Temperature "); break; case 0x04: // enclosure msg = QString::fromLatin1("Enclosure Temperature "); break; case 0x05: // enclosure target msg = QString::fromLatin1("Enclosure Target Temperature "); break; } msg.append(QString::fromLatin1("[%1] : %2")); msg = msg.arg(QString::number(number)) .arg(QString::number(double(temp), 'f', 2)); m_logWidget->appendLog(msg); } void AtCoreInstanceWidget::enableControls(bool b) { if (b) { layout()->removeWidget(m_logWidget); layout()->removeWidget(m_statusWidget); layout()->addWidget(m_statusWidget); m_advancedTab->layout()->addWidget(m_logWidget); } else { m_advancedTab->layout()->removeWidget(m_logWidget); layout()->addWidget(m_logWidget); layout()->removeWidget(m_statusWidget); layout()->addWidget(m_statusWidget); } m_tabWidget->setHidden(!b); m_toolBar->setEnabled(b); } bool AtCoreInstanceWidget::connected() { return (m_core.state() != AtCore::DISCONNECTED); } void AtCoreInstanceWidget::setFileCount(int count) { m_fileCount = count; togglePrintButtons(m_fileCount); } void AtCoreInstanceWidget::updateSerialPort(QStringList ports) { m_comboPort->clear(); //Remove any strings that match ttyS## from the port list. ports = ports.filter(QRegularExpression("^((?!ttyS\\d+).)*$")); if (!ports.isEmpty()) { m_comboPort->addItems(ports); m_logWidget->appendLog(i18n("Found %1 Ports", QString::number(ports.count()))); } else { QString portError(i18n("No available ports! Please connect a serial device to continue!")); if (!m_logWidget->endsWith(portError)) { m_logWidget->appendLog(portError); } } } void AtCoreInstanceWidget::updateProfileData() { m_settings.beginGroup("Profiles"); QStringList profiles = m_settings.childGroups(); m_settings.endGroup(); m_comboProfile->clear(); m_comboProfile->addItems(profiles); if (m_core.state() != AtCore::DISCONNECTED) { m_profileData = readProfile(); bool hBed = m_profileData["heatedBed"].toBool(); m_bedExtWidget->setBedThermoHidden(!hBed); connectBedTemperatureData(hBed); m_bedExtWidget->setBedMaxTemperature(m_profileData["bedTemp"].toInt()); m_bedExtWidget->setExtruderMaxTemperature(m_profileData["hotendTemp"].toInt()); } } void AtCoreInstanceWidget::togglePrintButtons(bool shown) { m_printAction->setVisible(shown); m_stopAction->setVisible(shown); } bool AtCoreInstanceWidget::isPrinting() { return (m_core.state() == AtCore::BUSY); } QMap AtCoreInstanceWidget::readProfile() { QString profile = m_comboProfile->currentText(); m_settings.beginGroup("Profiles"); m_settings.beginGroup(profile); QMap data{ {"bps", m_settings.value(QStringLiteral("bps"), QStringLiteral("115200"))} , {"bedTemp", m_settings.value(QStringLiteral("maximumTemperatureBed"), QStringLiteral("0"))} , {"hotendTemp", m_settings.value(QStringLiteral("maximumTemperatureExtruder"), QStringLiteral("0"))} , {"firmware", m_settings.value(QStringLiteral("firmware"), QStringLiteral("Auto-Detect"))} , {"postPause", m_settings.value(QStringLiteral("postPause"), QStringLiteral(""))} , {"heatedBed", m_settings.value(QStringLiteral("heatedBed"), true)} , {"name", profile} + , {"isCartesian", m_settings.value(QStringLiteral("isCartesian"), true)} + , {"dimensionX", m_settings.value(QStringLiteral("dimensionX"), QStringLiteral("200"))} + , {"dimensionY", m_settings.value(QStringLiteral("dimensionY"), QStringLiteral("200"))} + , {"dimensionZ", m_settings.value(QStringLiteral("dimensionZ"), QStringLiteral("180"))} + , {"radius", m_settings.value(QStringLiteral("radius"), QStringLiteral("200"))} + , {"z_delta_dimension", m_settings.value(QStringLiteral("z_delta_dimension"), QStringLiteral("180"))} }; m_settings.endGroup(); m_settings.endGroup(); return data; } void AtCoreInstanceWidget::connectBedTemperatureData(bool connected) { if (connected) { if (m_plotWidget->plots().contains((i18n("Actual Bed")))) { return; } m_plotWidget->addPlot(i18n("Actual Bed")); connect(&m_core.temperature(), &Temperature::bedTemperatureChanged, [this](const float & temp) { checkTemperature(0x00, 0, temp); m_plotWidget->appendPoint(i18n("Actual Bed"), temp); m_bedExtWidget->updateBedTemp(temp); }); m_plotWidget->addPlot(i18n("Target Bed")); connect(&m_core.temperature(), &Temperature::bedTargetTemperatureChanged, [this](const float & temp) { checkTemperature(0x01, 0, temp); m_plotWidget->appendPoint(i18n("Target Bed"), temp); m_bedExtWidget->updateBedTargetTemp(int(temp)); }); } else { if (m_plotWidget->plots().contains(i18n("Actual Bed"))) { m_plotWidget->removePlot(i18n("Actual Bed")); disconnect(&m_core.temperature(), &Temperature::bedTemperatureChanged, this, nullptr); m_plotWidget->removePlot(i18n("Target Bed")); disconnect(&m_core.temperature(), &Temperature::bedTargetTemperatureChanged, this, nullptr); } } } void AtCoreInstanceWidget::connectExtruderTemperatureData(bool connected) { if (connected) { if (m_plotWidget->plots().contains((i18n("Actual Ext.1")))) { return; } //Add Extruder. m_plotWidget->addPlot(i18n("Actual Ext.1")); connect(&m_core.temperature(), &Temperature::extruderTemperatureChanged, this, [this](const float & temp) { checkTemperature(0x02, 0, temp); m_plotWidget->appendPoint(i18n("Actual Ext.1"), temp); m_bedExtWidget->updateExtTemp(temp); }); m_plotWidget->addPlot(i18n("Target Ext.1")); connect(&m_core.temperature(), &Temperature::extruderTargetTemperatureChanged, this, [this](const float & temp) { checkTemperature(0x03, 0, temp); m_plotWidget->appendPoint(i18n("Target Ext.1"), temp); m_bedExtWidget->updateExtTargetTemp(int(temp)); }); } else { if (m_plotWidget->plots().contains(i18n("Actual Ext.1"))) { m_plotWidget->removePlot(i18n("Actual Ext.1")); disconnect(&m_core.temperature(), &Temperature::extruderTemperatureChanged, this, nullptr); m_plotWidget->removePlot(i18n("Target Ext.1")); disconnect(&m_core.temperature(), &Temperature::extruderTargetTemperatureChanged, this, nullptr); } } } + +QSize AtCoreInstanceWidget::bedSize() +{ + return m_bedSize; +} diff --git a/src/widgets/atcoreinstancewidget.h b/src/widgets/atcoreinstancewidget.h index c8b3aee..dd0abc2 100644 --- a/src/widgets/atcoreinstancewidget.h +++ b/src/widgets/atcoreinstancewidget.h @@ -1,105 +1,108 @@ /* Atelier KDE Printer Host for 3D Printing Copyright (C) <2017> Author: Lays Rodrigues - lays.rodrigues@kde.org Chris Rizzitello - rizzitello@kde.org This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "bedextruderwidget.h" /** * @todo write docs */ class AtCoreInstanceWidget : public QWidget { Q_OBJECT public: AtCoreInstanceWidget(QWidget *parent = nullptr); ~AtCoreInstanceWidget(); bool connected(); void setFileCount(int count); void startConnection(const QString &serialPort, const QMap &profile); public slots: bool isPrinting(); + QSize bedSize(); void printFile(const QUrl &fileName); void updateProfileData(); private: AtCore m_core; BedExtruderWidget *m_bedExtWidget; CommandWidget *m_commandWidget; int m_fileCount; LogWidget *m_logWidget; MovementWidget *m_movementWidget; PlotWidget *m_plotWidget; PrintWidget *m_printWidget; SdWidget *m_sdWidget; StatusWidget *m_statusWidget; QAction *m_printAction; QAction *m_stopAction; QComboBox *m_comboPort; QComboBox *m_comboProfile; QMap m_profileData; QPushButton *m_connectButton; QSettings m_settings; QSize m_iconSize; QString m_theme; QTabWidget *m_tabWidget; QToolBar *m_connectToolBar; QToolBar *m_toolBar; QWidget *m_advancedTab; QWidget *m_connectWidget; + QSize m_bedSize; void buildConnectionToolbar(); void buildToolbar(); void checkTemperature(uint sensorType, uint number, float temp); void connectButtonClicked(); void connectBedTemperatureData(bool connected); void connectExtruderTemperatureData(bool connected); void disableMotors(); void enableControls(bool b); void handlePrinterStatusChanged(AtCore::STATES newState); void initConnectsToAtCore(); void stopPrint(); QMap readProfile(); void pausePrint(); void print(); void updateSerialPort(QStringList ports); void togglePrintButtons(bool shown); signals: + void bedSizeChanged(QSize bedSize); void connectionChanged(QString name); void disableDisconnect(bool b); void extruderCountChanged(int count); void requestProfileDialog(); void requestFileChooser(); };