#include "OE_ui_viewportoptions.h" OE_ui_viewportOptions::OE_ui_viewportOptions(MainWindow* window, OE_root* root) { this->root = root; this->window = window; topGlWindowBar(); this->setMargin(0); this->setContentsMargins(0,0,0,0); onRefresh(); connect(getInterfaceDisplay(), SIGNAL(styleChange()), this, SLOT(onRefresh())); } QtMaterialIconButton* OE_ui_viewportOptions::setIconButton(QString iconFile, const QObject *receiver = NULL, const char * method = NULL) { QIcon icon; icon.addFile(iconFile, QSize(), QIcon::Normal, QIcon::Off); QtMaterialIconButton* button = new QtMaterialIconButton(icon); button->setUseThemeColors(false); button->setIconSize(QSize(25,25)); button->setRole(Material::Primary); button->setToolTip("test"); if (method) connect(button, SIGNAL(clicked()), receiver, method); return button; } void OE_ui_viewportOptions::topGlWindowBar() { setAlignment(Qt::AlignTop); setSpacing(4); setMargin(3); addWidget(setIconButton(":/resources/zoom_selection.svg",getInterfaceDisplay(),SLOT(zoomOnSelection()))); addWidget(setIconButton(":/resources/zoom_document.svg")); addSpacing(8); gridButton = setIconButton(":/resources/grid.svg", this, SLOT(onToggleGrid())); gridButton->setCheckable( true ); addWidget(gridButton); hoopButton = setIconButton(":/resources/hoop.svg", this, SLOT(onToggleHoop())); hoopButton->setCheckable( true ); addWidget(hoopButton); addSpacing(8); showCurvesButton = setIconButton(":/resources/show_curve.svg", this, SLOT(onToggleShowCurve())); showCurvesButton->setCheckable( true ); addWidget(showCurvesButton); showStitchButton = setIconButton(":/resources/show_stitch.svg", this, SLOT(onToggleShowStitch())); showStitchButton->setCheckable( true ); addWidget(showStitchButton); addSpacing(8); selectCurvesButton = setIconButton(":/resources/select_curve.svg", this, SLOT(onToggleSelectCurve())); selectCurvesButton->setCheckable( true ); addWidget(selectCurvesButton); selectStitchButton = setIconButton(":/resources/select_stitch.svg", this, SLOT(onToggleSelectStitch())); selectStitchButton->setCheckable( true ); addWidget(selectStitchButton); } OE_controller* OE_ui_viewportOptions::getController() { return this->root->interfaceDisplay->getController(); } OE_interfaceDisplay* OE_ui_viewportOptions::getInterfaceDisplay() { return this->root->interfaceDisplay; } OE_document* OE_ui_viewportOptions::getDocument() { return this->root->interfaceDisplay->getDocument(); } void OE_ui_viewportOptions::onRefresh() { gridButton->setChecked(getInterfaceDisplay()->style->drawGrid); hoopButton->setChecked(getInterfaceDisplay()->style->drawHoop); showCurvesButton->setChecked(getInterfaceDisplay()->style->drawCurves); showStitchButton->setChecked(getInterfaceDisplay()->style->drawStitches); selectCurvesButton->setChecked(getInterfaceDisplay()->style->selectCurves); selectStitchButton->setChecked(getInterfaceDisplay()->style->selectStitches); } void OE_ui_viewportOptions::onToggleGrid() { getInterfaceDisplay()->style->drawGrid = !getInterfaceDisplay()->style->drawGrid; getInterfaceDisplay()->update(); } void OE_ui_viewportOptions::onToggleHoop() { getInterfaceDisplay()->style->drawHoop = !getInterfaceDisplay()->style->drawHoop; getInterfaceDisplay()->update(); } void OE_ui_viewportOptions::onToggleShowCurve() { getInterfaceDisplay()->style->drawCurves = !getInterfaceDisplay()->style->drawCurves; getInterfaceDisplay()->update(); } void OE_ui_viewportOptions::onToggleShowStitch() { getInterfaceDisplay()->style->drawStitches = !getInterfaceDisplay()->style->drawStitches; getInterfaceDisplay()->update(); } void OE_ui_viewportOptions::onToggleSelectCurve() { getInterfaceDisplay()->style->selectCurves = !getInterfaceDisplay()->style->selectCurves; getInterfaceDisplay()->update(); } void OE_ui_viewportOptions::onToggleSelectStitch() { getInterfaceDisplay()->style->selectStitches = !getInterfaceDisplay()->style->selectStitches; getInterfaceDisplay()->update(); }