Skip to content
......@@ -24,12 +24,24 @@ OE_ui_toolBox::OE_ui_toolBox(MainWindow* window, OE_root* root)
tabs->setFont(buttonFont);
addFilesTools(tabs);
setFilesDisplayStyle(getInterfaceDisplay()->style);
addGuidesTools(tabs);
addStitchTools(tabs);
addThreadTools(tabs);
addTechnicalTools(tabs);
addMachineTools(tabs);
setGuidesDisplayStyle(getInterfaceDisplay()->addDisplayStyle());
addStitchTools(tabs);
setStitchDisplayStyle(getInterfaceDisplay()->addDisplayStyle());
addThreadTools(tabs);
setThreadDisplayStyle(getInterfaceDisplay()->addDisplayStyle());
addTechnicalTools(tabs);
setTechnicalDisplayStyle(getInterfaceDisplay()->addDisplayStyle());
addMachineTools(tabs);
setMachineDisplayStyle(getInterfaceDisplay()->addDisplayStyle());
connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));
drawerLeftLayout->setStretch(0,1);
setContentsMargins(0, 0, 0, 0);
......@@ -215,6 +227,40 @@ void OE_ui_toolBox::addMachineTools(QtMaterialToolTabs *tabs)
connect(window, SIGNAL(machineConnectionChanged(bool)), this, SLOT(on_machineConnectionChanged(bool)));
}
void OE_ui_toolBox::setFilesDisplayStyle(OE_display::OE_displayStyle* style){};
void OE_ui_toolBox::setGuidesDisplayStyle(OE_display::OE_displayStyle* style)
{
style->selectStitches = false;
}
void OE_ui_toolBox::setStitchDisplayStyle(OE_display::OE_displayStyle* style)
{
style->selectCurves = false;
}
void OE_ui_toolBox::setThreadDisplayStyle(OE_display::OE_displayStyle* style){};
void OE_ui_toolBox::setTechnicalDisplayStyle(OE_display::OE_displayStyle* style){};
void OE_ui_toolBox::setMachineDisplayStyle(OE_display::OE_displayStyle* style)
{
style->drawGrid = false;
style->drawCurves = false;
style->drawStitches = false;
style->drawCommands = true;
};
OE_controller* OE_ui_toolBox::getController()
{
return this->root->interfaceDisplay->getController();
}
OE_interfaceDisplay* OE_ui_toolBox::getInterfaceDisplay()
{
return this->root->interfaceDisplay;
}
OE_document* OE_ui_toolBox::getDocument()
{
return this->root->interfaceDisplay->getDocument();
}
void OE_ui_toolBox::sendKeyPulse(Qt::Key key, Qt::KeyboardModifiers modifiers)
{
QKeyEvent fakeKeyPress(QKeyEvent::Type::KeyPress, key, modifiers);
......@@ -223,6 +269,12 @@ void OE_ui_toolBox::sendKeyPulse(Qt::Key key, Qt::KeyboardModifiers modifiers)
root->interfaceDisplay->key(&fakeKeyRelease);
}
void OE_ui_toolBox::currentTabChanged(int tabId)
{
getInterfaceDisplay()->setDisplayStyle(tabId);
getInterfaceDisplay()->update();
}
void OE_ui_toolBox::on_actionNew_triggered()
{
window->addTab();
......
......@@ -15,6 +15,10 @@ class OE_ui_toolBox : public QWidget
public:
OE_ui_toolBox(MainWindow* window, OE_root* root);
OE_controller* getController();
OE_interfaceDisplay* getInterfaceDisplay();
OE_document* getDocument();
private:
OE_root* root;
MainWindow* window;
......@@ -28,9 +32,18 @@ private:
void addTechnicalTools(QtMaterialToolTabs *tabs);
void addMachineTools(QtMaterialToolTabs *tabs);
void setFilesDisplayStyle(OE_display::OE_displayStyle*);
void setGuidesDisplayStyle(OE_display::OE_displayStyle*);
void setStitchDisplayStyle(OE_display::OE_displayStyle*);
void setThreadDisplayStyle(OE_display::OE_displayStyle*);
void setTechnicalDisplayStyle(OE_display::OE_displayStyle*);
void setMachineDisplayStyle(OE_display::OE_displayStyle*);
void sendKeyPulse(Qt::Key key, Qt::KeyboardModifiers modifiers);
private slots:
void currentTabChanged(int);
void on_actionNew_triggered();
void on_actionOpen_triggered();
void on_actionSave_triggered();
......
......@@ -30,18 +30,21 @@ MainWindow::~MainWindow()
delete ui;
}
void MainWindow::keyPressEvent(QKeyEvent* event)
OE_root* MainWindow::getCurrentRoot()
{
QWidget* widget = ui->tabWidget->currentWidget();
OE_root* root = static_cast<OE_root*>(widget->property("OEroot").value<void*>());
root->display->keyPressEvent(event);
return static_cast<OE_root*>(widget->property("OEroot").value<void*>());
}
void MainWindow::keyPressEvent(QKeyEvent* event)
{
getCurrentRoot()->display->keyPressEvent(event);
}
void MainWindow::keyReleaseEvent(QKeyEvent* event)
{
QWidget* widget = ui->tabWidget->currentWidget();
OE_root* root = static_cast<OE_root*>(widget->property("OEroot").value<void*>());
root->display->keyReleaseEvent(event);
getCurrentRoot()->display->keyReleaseEvent(event);
}
void MainWindow::addTab()
......@@ -362,8 +365,6 @@ void MainWindow::machineLoad()
{
if (machine)
{
QWidget* widget = ui->tabWidget->currentWidget();
OE_root* root = static_cast<OE_root*>(widget->property("OEroot").value<void*>());
root->controller->sendInstPoint(machine.get());
getCurrentRoot()->controller->sendInstPoint(machine.get());
}
}
......@@ -2,6 +2,7 @@
#define MAINWINDOW_H
#include <QMainWindow>
#include <QtWidgets/qlabel.h>
#include <memory>
#include <machine.h>
......@@ -25,6 +26,7 @@ class MainWindow;
}
class OE_interfaceDisplay;
class OE_root;
class OE_ui_toolBox;
class OE_ui_stitchList;
......@@ -50,6 +52,8 @@ public:
void machineRun();
void machineLoad();
OE_root* getCurrentRoot();
private:
OE_interfaceDisplay* getItfDisplay();
void sendKeyPulse(Qt::Key key, Qt::KeyboardModifiers modifiers);
......
......@@ -69,11 +69,9 @@ bool OE_stitchs::getPoint(uint16_t nb, vector_2d* pt)
return false;
}
std::vector<vector_2d> OE_stitchs::getPoints()
const std::vector<vector_2d>& OE_stitchs::getPoints()
{
std::vector<vector_2d> out;
out = pts;
return out;
return pts;
}
int OE_stitchs::getNpts()
......