Newer
Older
#include "OE_ui_toolbox.h"
#include <QtWidgets/QFormLayout>
#include <qtmaterialtooltabs_internal.h>
#include "ui_mainwindow.h"
OE_ui_toolBox::OE_ui_toolBox(MainWindow* window, OE_root* root)
{
this->root = root;
this->window = window;
buttonFont = QFont("Roboto", 8, QFont::Medium);
setFixedWidth(150);
setSizePolicy(QSizePolicy ::Fixed , QSizePolicy ::Expanding );
QVBoxLayout *drawerLeftLayout = new QVBoxLayout;
setLayout(drawerLeftLayout);
drawerLeftLayout->setMargin(0);
drawerLeftLayout->setContentsMargins(0,0,0,0);
QtMaterialToolTabs *tabs = new QtMaterialToolTabs;
tabs->setSizePolicy(QSizePolicy ::Expanding , QSizePolicy ::Expanding );
drawerLeftLayout->addWidget(tabs);
tabs->setFont(buttonFont);
addFilesTools(tabs);
setFilesDisplayStyle(getInterfaceDisplay()->style);
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);
}
QtMaterialFlatButton* OE_ui_toolBox::setButton(QString name, const QObject *receiver = NULL, const char * method = NULL)
{
QtMaterialFlatButton* button = new QtMaterialFlatButton(name);
button->setFont(buttonFont);
button->setUseThemeColors(true);
button->setHaloVisible(false);
button->setTextAlignment(Qt::AlignLeft);
button->setMinimumHeight(0);
if (method)
connect(button, SIGNAL(clicked(bool)), receiver, method);
QtMaterialFlatButton* OE_ui_toolBox::setButton(QString name,QString iconFile, const QObject *receiver = NULL, const char * method = NULL)
QtMaterialFlatButton* newButton = setButton(name, receiver, method);
QIcon icon;
icon.addFile(iconFile, QSize(), QIcon::Normal, QIcon::Off);
newButton->setIcon(icon);
//newButton->setIconPlacement(Material::ButtonIconPlacement::RightIcon);
return newButton;
}
void OE_ui_toolBox::addFilesTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Files");
tabs->addTab(curTab);
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("New",":/resources/new.svg", this, SLOT(on_actionNew_triggered())));
toolLayout->addWidget(setButton("Open",":/resources/open.svg", getInterfaceDisplay(), SLOT(openFile())));
toolLayout->addWidget(setButton("Save as",":/resources/save.svg", getInterfaceDisplay(), SLOT(saveFile())));
toolLayout->addStretch();
}
void OE_ui_toolBox::addGuidesTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Curves");
tabs->addTab(curTab);
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("Close", getInterfaceDisplay(), SLOT(closeSelectedCurve())));
//toolLayout->addWidget(setButton("Reverse", this, SLOT(on_actionReverse_curve_R_triggered())));
QLabel* label = new QLabel("Turn: ");
label->setFont(buttonFont);
label->setAlignment(Qt::AlignCenter);
toolLayout->addWidget(label);
QHBoxLayout *turnLayout = new QHBoxLayout();//curTab->content());
toolLayout->addLayout(turnLayout);
turnLayout->addWidget(setButton("Right"));
turnLayout->addWidget(setButton("Left"));
turnLayout->addWidget(setButton("360°"));
toolLayout->addWidget(setButton("Add curve"));
toolLayout->addStretch();
}
void OE_ui_toolBox::addStitchTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Stitches");
tabs->addTab(curTab);
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("New line", getInterfaceDisplay(), SLOT(newLinestitch())));
toolLayout->addWidget(setButton("New birail", getInterfaceDisplay(), SLOT(newBirailstitch())));
toolLayout->addWidget(setButton("New fill", getInterfaceDisplay(), SLOT(newFillstitch())));
//toolLayout->addWidget(setButton("Reverse selected", SLOT(on_actionReverse_curve_R_triggered())));
toolLayout->addStretch();
QLabel* label = new QLabel("-- favorite Paterns --");
label->setFont(buttonFont);
label->setAlignment(Qt::AlignCenter);
toolLayout->addWidget(label);
QGridLayout * paternLayout = new QGridLayout();
toolLayout->addLayout(paternLayout);
paternLayout->addWidget(setButton("1", this, SLOT(on_actionPattern1_triggered())),0,0,1,1);
paternLayout->addWidget(setButton("2", this, SLOT(on_actionPattern2_triggered())),0,1,1,1);
paternLayout->addWidget(setButton("3", this, SLOT(on_actionPattern3_triggered())),0,2,1,1);
/*paternLayout->addWidget(setButton("3",SLOT(on_actionPattern3_triggered())),0,2,1,1);
QtMaterialFlatButton* button = new QtMaterialFlatButton("3");
button->setFont(buttonFont);
button->setUseThemeColors(true);
button->setHaloVisible(false);
button->setTextAlignment(Qt::AlignLeft);
button->setMinimumHeight(0);
button->addAction(window->actionPattern3);*/
paternLayout->addWidget(setButton("4", this, SLOT(on_actionPattern4_triggered())),0,3,1,1);
paternLayout->addWidget(setButton("5", this, SLOT(on_actionPattern5_triggered())),0,4,1,1);
paternLayout->addWidget(setButton("6", this, SLOT(on_actionPattern6_triggered())),1,0,1,1);
paternLayout->addWidget(setButton("7", this, SLOT(on_actionPattern7_triggered())),1,1,1,1);
paternLayout->addWidget(setButton("8", this, SLOT(on_actionPattern8_triggered())),1,2,1,1);
paternLayout->addWidget(setButton("9", this, SLOT(on_actionPattern9_triggered())),1,3,1,1);
paternLayout->addWidget(setButton("10", this, SLOT(on_actionPattern9_triggered())),1,4,1,1);
}
void OE_ui_toolBox::addThreadTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Threads");
tabs->addTab(curTab);
//curTab->button()->setIcon(icon);
//curTab->button()->setIconSize(QSize(22, 22));
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("New thread from lib"));
toolLayout->addStretch();
QLabel* label = new QLabel("-- Used threads --");
label->setFont(buttonFont);
label->setAlignment(Qt::AlignCenter);
toolLayout->addWidget(label);
QGridLayout * paternLayout = new QGridLayout();
toolLayout->addLayout(paternLayout);
paternLayout->addWidget(setButton("1", this, SLOT(on_actionPattern1_triggered())),0,0,1,1);
paternLayout->addWidget(setButton("2", this, SLOT(on_actionPattern2_triggered())),0,1,1,1);
paternLayout->addWidget(setButton("3", this, SLOT(on_actionPattern3_triggered())),0,2,1,1);
paternLayout->addWidget(setButton("4", this, SLOT(on_actionPattern4_triggered())),0,3,1,1);
paternLayout->addWidget(setButton("5", this, SLOT(on_actionPattern5_triggered())),0,4,1,1);
paternLayout->addWidget(setButton("6", this, SLOT(on_actionPattern6_triggered())),1,0,1,1);
paternLayout->addWidget(setButton("+", this, SLOT(on_actionPattern5_triggered())),1,1,1,1);
}
void OE_ui_toolBox::addTechnicalTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Technical");
tabs->addTab(curTab);
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("underlay"));
toolLayout->addWidget(setButton("Push/pull"));
toolLayout->addWidget(setButton("cut link"));
toolLayout->addWidget(setButton("set speed"));
toolLayout->addStretch();
}
void OE_ui_toolBox::addMachineTools(QtMaterialToolTabs *tabs)
{
QtMaterialToolTab* curTab = new QtMaterialToolTab("Machine control");
tabs->addTab(curTab);
QVBoxLayout *toolLayout = new QVBoxLayout(curTab->content());
toolLayout->setMargin(0);
toolLayout->setSpacing(0);
toolLayout->setContentsMargins(0,0,0,0);
toolLayout->addWidget(setButton("Connect", window, SLOT(on_actionConnectToMachine_triggered(bool))));
toolLayout->addWidget(setButton("Push", this, SLOT(on_actionMachineLoad_triggered())));
toolLayout->addWidget(setButton("Run", this, SLOT(on_actionMachineRun_triggered())));
connect(window, SIGNAL(machineConnectionChanged(bool)), this, SLOT(on_machineConnectionChanged(bool)));
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
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::currentTabChanged(int tabId)
{
getInterfaceDisplay()->setDisplayStyle(tabId);
getInterfaceDisplay()->update();
}
void OE_ui_toolBox::on_actionNew_triggered() { window->addTab();}
void OE_ui_toolBox::on_actionPattern1_triggered() { getInterfaceDisplay()->SetSelectedStitchPattern(0);}
void OE_ui_toolBox::on_actionPattern2_triggered() { getInterfaceDisplay()->SetSelectedStitchPattern(1);}
void OE_ui_toolBox::on_actionPattern3_triggered() { getInterfaceDisplay()->SetSelectedStitchPattern(2);}
void OE_ui_toolBox::on_actionPattern4_triggered() { getInterfaceDisplay()->SetSelectedStitchPattern(3);}
void OE_ui_toolBox::on_actionPattern5_triggered() { getInterfaceDisplay()->SetSelectedStitchPattern(4);}
void OE_ui_toolBox::on_actionPattern6_triggered() { getInterfaceDisplay()->SetSelectedStitchPattern(5);}
void OE_ui_toolBox::on_actionPattern7_triggered() { getInterfaceDisplay()->SetSelectedStitchPattern(6);}
void OE_ui_toolBox::on_actionPattern8_triggered() { getInterfaceDisplay()->SetSelectedStitchPattern(7);}
void OE_ui_toolBox::on_actionPattern9_triggered() { getInterfaceDisplay()->SetSelectedStitchPattern(8);}
void OE_ui_toolBox::on_actionMachineRun_triggered()
{
window->machineRun();
}
void OE_ui_toolBox::on_actionMachineLoad_triggered()
{
window->machineLoad();
}
void OE_ui_toolBox::on_machineConnectionChanged(bool connected)
{
// ui->actionMachineRun->setEnabled(connected);
// ui->actionMachineLoad->setEnabled(connected);
}