void MainWindow::begin() { //receiveList("Starting File Send."); resetProgress(); int ret = QMessageBox::No; if((ui->lcdWorkNumberX->value()!=0)||(ui->lcdWorkNumberY->value()!=0)||(ui->lcdWorkNumberZ->value()!=0)) { QMessageBox msgBox; msgBox.setText("Wish to \"zero position\" before beginning?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Yes); ret = msgBox.exec(); if(ret ==QMessageBox::Yes) setHome(); } if(ret!=QMessageBox::Cancel) { ui->tabAxisVisualizer->setEnabled(false); ui->groupBoxManualGCode->setEnabled(false); ui->Begin->setEnabled(false); ui->Stop->setEnabled(true); ui->progressFileSend->setEnabled(true); ui->outputRuntime->setEnabled(true); ui->labelRuntime->setEnabled(true); ui->openFile->setEnabled(false); ui->btnGRBL->setEnabled(false); ui->btnUnlockGrbl->setEnabled(false); ui->btnSetHome->setEnabled(false); ui->btnGoHomeSafe->setEnabled(false); emit sendFile(ui->filePath->text()); } }
void Logbook::setHome(const linkItemId &bookmarkItemId) { BookmarkItem *item = getBookmark(bookmarkItemId); if ( item ) { // Ensuring the item actually exists setHome(*item); delete item; } }
void Navigator::doKeyPress (QKeyEvent *key) { switch (key->key()) { case Qt::Key_Delete: key->accept(); emit keyPress(key->state(), key->key()); break; case Qt::Key_Left: // segfaults if we dont trap this case Qt::Key_Right: // segfaults if we dont trap this key->accept(); break; case Qt::Key_Enter: case Qt::Key_Return: key->accept(); checkDirectory(item(currentItem())); break; case Qt::Key_Home: key->accept(); setHome(); Q3ListBox::keyPressEvent(key); break; default: key->accept(); Q3ListBox::keyPressEvent(key); break; } }
void Logbook::setHome(const QString &url) { BookmarkItem *item = getBookmark(url); if ( !item ) { addBookmark(QString(), url); item = getBookmark(url); } if ( item ) { // Ensuring the item actually exists setHome(*item); delete item; } }
void QtVCardAddressLabelField::setAddressLabel(const VCard::AddressLabel& addressLabel) { setPreferred(addressLabel.isPreferred); setHome(addressLabel.isHome); setWork(addressLabel.isWork); getTagComboBox()->setTag("postal", addressLabel.isPostal); getTagComboBox()->setTag("parcel", addressLabel.isParcel); domesticRadioButton->setChecked(addressLabel.deliveryType == VCard::DomesticDelivery); internationalRadioButton->setChecked(addressLabel.deliveryType == VCard::InternationalDelivery); std::string joinedLines = boost::algorithm::join(addressLabel.lines, "\n"); addressLabelPlainTextEdit->setPlainText(P2QSTRING(joinedLines)); }
Printer::Printer(const char *file, int baudRate, int protocol, float home_x, float home_y, float home_z, float home_e) : fd(serialOpen(file, baudRate)), file(fdopen(fd, "rw")), serialReadNum(0), running(true), started(false), protocol(protocol), x(NAN), y(NAN), z(NAN), e(NAN), f(NAN), lineNumber(-1), confirmedLineNumber(-1) { if(fd == -1) { throw "Blah :|"; } std::unique_lock<std::mutex> writeLock(writeMutex); serialReadThread = std::thread(&Printer::serialRead, this); while(!started) { signalNextCommand.wait(writeLock); } writeLock.unlock(); serialWriteThread = std::thread(&Printer::serialWrite, this); setHome(home_x, home_y, home_z, home_e); GCode gc; gc.setM(110); addCommand(gc); gc = GCode(); gc.setM(111); gc.setS(7); addCommand(gc); gc = GCode(); gc.setM(114); addCommand(gc); gc = GCode(); gc.setM(84); addCommand(gc); }
void QtVCardAddressField::setAddress(const VCard::Address& address) { setPreferred(address.isPreferred); setHome(address.isHome); setWork(address.isWork); getTagComboBox()->setTag("postal", address.isPostal); getTagComboBox()->setTag("parcel", address.isParcel); domesticRadioButton->setChecked(address.deliveryType == VCard::DomesticDelivery); internationalRadioButton->setChecked(address.deliveryType == VCard::InternationalDelivery); streetLineEdit->setText(P2QSTRING(address.street)); poboxLineEdit->setText(P2QSTRING(address.poBox)); addressextLineEdit->setText(P2QSTRING(address.addressExtension)); cityLineEdit->setText(P2QSTRING(address.locality)); pocodeLineEdit->setText(P2QSTRING(address.postalCode)); regionLineEdit->setText(P2QSTRING(address.region)); countryLineEdit->setText(P2QSTRING(address.country)); }
void MainWindow::begin() { if (ui->tabAxisVisualizer->currentIndex() != TAB_VISUALIZER_INDEX) { emit ui->tabAxisVisualizer->setCurrentIndex(TAB_VISUALIZER_INDEX); } //receiveList("Starting File Send."); resetProgress(); int ret = QMessageBox::No; if((ui->lcdWorkNumberX->value()!=0)||(ui->lcdWorkNumberY->value()!=0)||(ui->lcdWorkNumberZ->value()!=0) || (ui->lcdWorkNumberC->value()!=0)) { QMessageBox msgBox; msgBox.setText(tr("Do you want to zero the displayed position before proceeding?")); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); msgBox.setDefaultButton(QMessageBox::Yes); ret = msgBox.exec(); if(ret ==QMessageBox::Yes) setHome(); } if(ret!=QMessageBox::Cancel) { ui->tabAxisVisualizer->setEnabled(false); ui->comboCommand->setEnabled(false); ui->labelCommand->setEnabled(false); ui->Begin->setEnabled(false); ui->Stop->setEnabled(true); ui->progressFileSend->setEnabled(true); ui->outputRuntime->setEnabled(true); ui->labelRuntime->setEnabled(true); ui->openFile->setEnabled(false); ui->btnGRBL->setEnabled(false); ui->btnUnlockGrbl->setEnabled(false); ui->btnSetHome->setEnabled(false); ui->btnGoHomeSafe->setEnabled(false); emit sendFile(ui->filePath->text()); } }
String KnitControl::run(char c) { String res = "nop"; bool processed = false; switch (c){ case ' ': processed=true; break; case 'a': // toggle BACK servos case 'A': processed = true; stepsToDo=0; lastStepsToDo=0; res = "Trying to ABORT!"; break; case 'b': // toggle BACK servos case 'B': processed = true; sm->setFB(false,ServoMgr::Toggle); res = "Toggling BACK servos."; break; case 'c': // toggle BACK servos case 'C': processed = true; stepsToDo=0; lastStepsToDo=0; homed = awayed = false; curPos = 0; awayPos = maxSteps; res = "Settings Clearde!"; break; case 'f': // toggle FRONT servos case 'F': processed = true; sm->setFB(true,ServoMgr::Toggle); res = "Toggling FRONT servos."; break; case 'G': case 'g': // just go until we can go no more processed = true; if (homed && awayed){ stepsToDo=-1; lastStepsToDo=0; res = "Going for it!"; } else{ res = "Better HOME and AWAY first..."; } break; case 'h': case 'H': // set the current position as home setHome(); processed = true; res = "Homed!"; break; case 'k': // toggle FRONT servos case 'K': processed = true; sm->setServos2Knit(dir); res = String("Servos set to knit: ") + String(dir ? "LEFT" : "RIGHT"); break; case 'l': case 'L': // take a step left processed = true; setDir(true); res = "Direction: LEFT!"; break; case 'n': // chang to needle mode, i.e. numbers entered refer to needles case 'N': processed = true; needleMode = true; res = "Needle Movement Mode activited!"; break; case 'p': // display curren position case 'P': processed = true; res = "Current Position: " + String(curPos); // NOTE: the string 'Current' is parsed by Processing GUI, do not remove it! break; case 'r': // take one step right case 'R': processed = true; setDir(false); res = "Direction: RIGHT!"; break; case 's': // switch tostep mode: numbers entered refer to steps case 'S': processed = true; needleMode = false; res = "Step Movement Mode activited!"; break; case 't': // toggle TOP servo case 'T': processed = true; sm->toggle(ServoMgr::Top); res = "Toggling TOP servo."; break; case 'v': // Visualize status case 'V': processed = true; res = getStatus(); break; case 'y': case 'Y': // set the current position as home processed = true; if(homed){ setAway(); res = "Awayed!"; } else{ res = "Please Home before setting Away!"; } break; case 'z': // all servos OUT case 'Z': processed = true; for (int i=0;i<ServoMgr::nbServos;i++){ sm->set(i,false); } res = "Servos set to OUT."; break; } if (!processed){ if (c >= '0' && c <= '9'){ int nbSteps = ((c -'0') * 5) + 1; if (needleMode){ moveNeedles(nbSteps); } else{ moveSteps(nbSteps); } } } return res; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), absoluteAfterAxisAdj(false), checkLogWrite(false), sliderPressed(false), sliderTo(0.0), sliderZCount(0) { // Setup our application information to be used by QSettings QCoreApplication::setOrganizationName(COMPANY_NAME); QCoreApplication::setOrganizationDomain(DOMAIN_NAME); QCoreApplication::setApplicationName(APPLICATION_NAME); // required if passing the object by reference into signals/slots qRegisterMetaType<Coord3D>("Coord3D"); qRegisterMetaType<PosItem>("PosItem"); qRegisterMetaType<ControlParams>("ControlParams"); ui->setupUi(this); readSettings(); info("%s has started", GRBL_CONTROLLER_NAME_AND_VERSION); // see http://blog.qt.digia.com/2010/06/17/youre-doing-it-wrong/ // The thread points out that the documentation for QThread is wrong :) and // you should NOT subclass from QThread and override run(), rather, // attach your QOBJECT to a thread and use events (signals/slots) to communicate. gcode.moveToThread(&gcodeThread); timer.moveToThread(&timerThread); ui->lcdWorkNumberX->setDigitCount(8); ui->lcdMachNumberX->setDigitCount(8); ui->lcdWorkNumberY->setDigitCount(8); ui->lcdMachNumberY->setDigitCount(8); ui->lcdWorkNumberZ->setDigitCount(8); ui->lcdMachNumberZ->setDigitCount(8); //buttons connect(ui->btnOpenPort,SIGNAL(clicked()),this,SLOT(openPort())); connect(ui->btnGRBL,SIGNAL(clicked()),this,SLOT(setGRBL())); connect(ui->DecXBtn,SIGNAL(clicked()),this,SLOT(decX())); connect(ui->DecYBtn,SIGNAL(clicked()),this,SLOT(decY())); connect(ui->DecZBtn,SIGNAL(clicked()),this,SLOT(decZ())); connect(ui->IncXBtn,SIGNAL(clicked()),this,SLOT(incX())); connect(ui->IncYBtn,SIGNAL(clicked()),this,SLOT(incY())); connect(ui->IncZBtn,SIGNAL(clicked()),this,SLOT(incZ())); connect(ui->btnSetHome,SIGNAL(clicked()),this,SLOT(setHome())); connect(ui->Command,SIGNAL(editingFinished()),this,SLOT(gotoXYZ())); connect(ui->Begin,SIGNAL(clicked()),this,SLOT(begin())); connect(ui->openFile,SIGNAL(clicked()),this,SLOT(openFile())); connect(ui->Stop,SIGNAL(clicked()),this,SLOT(stop())); connect(ui->SpindleOn,SIGNAL(toggled(bool)),this,SLOT(toggleSpindle())); connect(ui->chkRestoreAbsolute,SIGNAL(toggled(bool)),this,SLOT(toggleRestoreAbsolute())); connect(ui->actionOptions,SIGNAL(triggered()),this,SLOT(getOptions())); connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close())); connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(showAbout())); connect(ui->btnResetGrbl,SIGNAL(clicked()),this,SLOT(grblReset())); connect(ui->btnUnlockGrbl,SIGNAL(clicked()),this,SLOT(grblUnlock())); connect(ui->btnGoHomeSafe,SIGNAL(clicked()),this,SLOT(goHomeSafe())); connect(ui->verticalSliderZJog,SIGNAL(valueChanged(int)),this,SLOT(zJogSliderDisplay(int))); connect(ui->verticalSliderZJog,SIGNAL(sliderPressed()),this,SLOT(zJogSliderPressed())); connect(ui->verticalSliderZJog,SIGNAL(sliderReleased()),this,SLOT(zJogSliderReleased())); connect(this, SIGNAL(sendFile(QString)), &gcode, SLOT(sendFile(QString))); connect(this, SIGNAL(openPort(QString,QString)), &gcode, SLOT(openPort(QString,QString))); connect(this, SIGNAL(closePort(bool)), &gcode, SLOT(closePort(bool))); connect(this, SIGNAL(sendGcode(QString)), &gcode, SLOT(sendGcode(QString))); connect(this, SIGNAL(gotoXYZ(QString)), &gcode, SLOT(gotoXYZ(QString))); connect(this, SIGNAL(axisAdj(char, float, bool, bool, int)), &gcode, SLOT(axisAdj(char, float, bool, bool, int))); connect(this, SIGNAL(setResponseWait(ControlParams)), &gcode, SLOT(setResponseWait(ControlParams))); connect(this, SIGNAL(shutdown()), &gcodeThread, SLOT(quit())); connect(this, SIGNAL(shutdown()), &timerThread, SLOT(quit())); connect(this, SIGNAL(setProgress(int)), ui->progressFileSend, SLOT(setValue(int))); connect(this, SIGNAL(setRuntime(QString)), ui->outputRuntime, SLOT(setText(QString))); connect(this, SIGNAL(sendSetHome()), &gcode, SLOT(grblSetHome())); connect(this, SIGNAL(sendGrblReset()), &gcode, SLOT(sendGrblReset())); connect(this, SIGNAL(sendGrblUnlock()), &gcode, SLOT(sendGrblUnlock())); connect(this, SIGNAL(goToHome()), &gcode, SLOT(goToHome())); connect(this, SIGNAL(setItems(QList<PosItem>)), ui->wgtVisualizer, SLOT(setItems(QList<PosItem>))); connect(&gcode, SIGNAL(sendMsg(QString)),this,SLOT(receiveMsg(QString))); connect(&gcode, SIGNAL(portIsClosed(bool)), this, SLOT(portIsClosed(bool))); connect(&gcode, SIGNAL(portIsOpen(bool)), this, SLOT(portIsOpen(bool))); connect(&gcode, SIGNAL(addList(QString)),this,SLOT(receiveList(QString))); connect(&gcode, SIGNAL(addListFull(QStringList)),this,SLOT(receiveListFull(QStringList))); connect(&gcode, SIGNAL(addListOut(QString)),this,SLOT(receiveListOut(QString))); connect(&gcode, SIGNAL(stopSending()), this, SLOT(stopSending())); connect(&gcode, SIGNAL(setCommandText(QString)), ui->Command, SLOT(setText(QString))); connect(&gcode, SIGNAL(setProgress(int)), ui->progressFileSend, SLOT(setValue(int))); connect(&gcode, SIGNAL(adjustedAxis()), this, SLOT(adjustedAxis())); connect(&gcode, SIGNAL(resetTimer(bool)), &timer, SLOT(resetTimer(bool))); connect(&gcode, SIGNAL(enableGrblDialogButton()), this, SLOT(enableGrblDialogButton())); connect(&gcode, SIGNAL(updateCoordinates(Coord3D,Coord3D)), this, SLOT(updateCoordinates(Coord3D,Coord3D))); connect(&gcode, SIGNAL(setLastState(QString)), ui->outputLastState, SLOT(setText(QString))); connect(&gcode, SIGNAL(setUnitsWork(QString)), ui->outputUnitsWork, SLOT(setText(QString))); connect(&gcode, SIGNAL(setUnitsMachine(QString)), ui->outputUnitsMachine, SLOT(setText(QString))); connect(&gcode, SIGNAL(setLivePoint(double, double, bool)), ui->wgtVisualizer, SLOT(setLivePoint(double, double, bool))); connect(&gcode, SIGNAL(setVisCurrLine(int)), ui->wgtVisualizer, SLOT(setVisCurrLine(int))); connect(&timer, SIGNAL(setRuntime(QString)), ui->outputRuntime, SLOT(setText(QString))); timerThread.start(); gcodeThread.start(); ui->comboStep->addItem("0.01"); ui->comboStep->addItem("0.1"); ui->comboStep->addItem("1"); ui->comboStep->addItem("10"); ui->comboStep->setCurrentIndex(2); ui->statusList->setUniformItemSizes(true); // Does not work correctly for horizontal scrollbar: //MyItemDelegate *scrollDelegate = new MyItemDelegate(ui->statusList); //scrollDelegate->setWidth(600); //ui->statusList->setItemDelegate(scrollDelegate); scrollStatusTimer.start(); // Cool utility class off Google code that enumerates COM ports in platform-independent manner QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); int portIndex = -1; for (int i = 0; i < ports.size(); i++) { ui->cmbPort->addItem(ports.at(i).portName.toLocal8Bit().constData()); if (ports.at(i).portName == lastOpenPort) portIndex = i; //diag("port name: %s\n", ports.at(i).portName.toLocal8Bit().constData()); //diag("friendly name: %s\n", ports.at(i).friendName.toLocal8Bit().constData()); //diag("physical name: %s\n", ports.at(i).physName.toLocal8Bit().constData()); //diag("enumerator name: %s\n", ports.at(i).enumName.toLocal8Bit().constData()); //diag("===================================\n\n"); } if (portIndex >= 0) { // found matching port ui->cmbPort->setCurrentIndex(portIndex); } else if (lastOpenPort.size() > 0) { // did not find matching port // This code block is used to restore a port to view that isn't visible to QextSerialEnumerator ui->cmbPort->addItem(lastOpenPort.toLocal8Bit().constData()); if (ports.size() > 0) ui->cmbPort->setCurrentIndex(ports.size()); else ui->cmbPort->setCurrentIndex(0); } int baudRates[] = { 9600, 19200, 38400, 57600, 115200 }; int baudRateCount = sizeof baudRates / sizeof baudRates[0]; int baudRateIndex = 0; for (int i = 0; i < baudRateCount; i++) { QString baudRate = QString::number(baudRates[i]); ui->comboBoxBaudRate->addItem(baudRate); if (baudRate == lastBaudRate) { baudRateIndex = i; } } ui->comboBoxBaudRate->setCurrentIndex(baudRateIndex); ui->tabAxisVisualizer->setEnabled(false); ui->groupBoxSendFile->setEnabled(true); ui->groupBoxManualGCode->setEnabled(false); ui->Begin->setEnabled(false); ui->Stop->setEnabled(false); ui->progressFileSend->setEnabled(false); ui->outputRuntime->setEnabled(false); ui->labelRuntime->setEnabled(false); ui->btnGRBL->setEnabled(false); ui->btnSetHome->setEnabled(false); ui->btnResetGrbl->setEnabled(false); ui->btnUnlockGrbl->setEnabled(false); ui->btnGoHomeSafe->setEnabled(false); styleSheet = ui->btnOpenPort->styleSheet(); ui->statusList->setEnabled(true); ui->openFile->setEnabled(true); this->setWindowTitle(GRBL_CONTROLLER_NAME_AND_VERSION); QSettings settings; QString useAggrPreload = settings.value(SETTINGS_USE_AGGRESSIVE_PRELOAD, "true").value<QString>(); controlParams.useAggressivePreload = useAggrPreload == "true"; if (!controlParams.useAggressivePreload && !promptedAggrPreload) { QMessageBox msgBox; msgBox.setText("You appear to have upgraded to the latest version of Grbl Controller. " "Please be aware that as of version 3.4 the default behavior of sending commands " "to Grbl has been changed to send them as fast as possible (Aggressive preload mode).\n\n" "Your settings have been changed to enable this mode. Why? Because it provides the most " "optimal use of Grbl and greatly reduces the time to finish a typical job.\n\n" "What does this mean to you? " "Arc commands will now run smoother and faster than before, which may " "cause your spindle to work slightly harder, so please run some tests first. " "Alternately, go to the Options dialog and manually disable Aggressive Preload"); msgBox.exec(); controlParams.useAggressivePreload = true; settings.setValue(SETTINGS_USE_AGGRESSIVE_PRELOAD, controlParams.useAggressivePreload); } promptedAggrPreload = true; emit setResponseWait(controlParams); }
void player::chooseHouse(WINDOW*& interfaceWindow, std::vector<house>& houseList, bool userOrNot) { int interfacePrintX = 77; int interfacePrintY = 5; if(home.name.size() > 1) { money = money + home.worth; // for buying second house and selling other } mvwprintw(interfaceWindow, interfacePrintY-2, interfacePrintX, " "); mvwprintw(interfaceWindow, interfacePrintY-1, interfacePrintX, " "); mvwprintw(interfaceWindow, interfacePrintY, interfacePrintX, " "); mvwprintw(interfaceWindow, interfacePrintY+1, interfacePrintX, " "); wrefresh(interfaceWindow); bool loopFinish = false; house houseOne; house houseTwo; house houseThree; int randomOne; int randomTwo; int randomThree; while(loopFinish != true) { randomOne = rand() % houseList.size(); randomTwo = rand() % houseList.size(); randomThree = rand() % houseList.size(); if(randomOne == randomTwo || randomTwo == randomThree || randomOne == randomThree) { loopFinish = false; } else { loopFinish = true; } } houseOne = houseList.at(randomOne); houseTwo = houseList.at(randomTwo); houseThree = houseList.at(randomThree); if(userOrNot == true) { mvwprintw(interfaceWindow, interfacePrintY-2, interfacePrintX, "Choose a House: "); mvwprintw(interfaceWindow, interfacePrintY-1, interfacePrintX, "(1) "); mvwprintw(interfaceWindow, interfacePrintY-1, interfacePrintX+4, houseOne.name.c_str()); mvwprintw(interfaceWindow, interfacePrintY-1, interfacePrintX+22, "Cost: $"); mvwprintw(interfaceWindow, interfacePrintY-1, interfacePrintX+28, "%d", houseOne.cost); mvwprintw(interfaceWindow, interfacePrintY, interfacePrintX, "(2) "); mvwprintw(interfaceWindow, interfacePrintY, interfacePrintX+4, houseTwo.name.c_str()); mvwprintw(interfaceWindow, interfacePrintY, interfacePrintX+22, "Cost: $"); mvwprintw(interfaceWindow, interfacePrintY, interfacePrintX+28, "%d", houseTwo.cost); mvwprintw(interfaceWindow, interfacePrintY+1, interfacePrintX, "(3) "); mvwprintw(interfaceWindow, interfacePrintY+1, interfacePrintX+4, houseThree.name.c_str()); mvwprintw(interfaceWindow, interfacePrintY+1, interfacePrintX+22, "Cost: $"); mvwprintw(interfaceWindow, interfacePrintY+1, interfacePrintX+28, "%d", houseThree.cost); wrefresh(interfaceWindow); bool goodInput = false; while(goodInput != true) { char houseDecision = getch(); if(houseDecision == '1' || houseDecision == '2' || houseDecision == '3') { goodInput = true; if(houseDecision == '1') { setHome(houseOne); houseList.erase(houseList.begin() + randomOne); } else if(houseDecision == '2') { setHome(houseTwo); houseList.erase(houseList.begin() + randomTwo); } else if(houseDecision == '3') { setHome(houseThree); houseList.erase(houseList.begin() + randomThree); } money = money - home.cost; } else { goodInput = false; } } } else if(userOrNot == false) { int randChoice = rand() % 3; if(randChoice == 0) { setHome(houseOne); houseList.erase(houseList.begin() + randomOne); } else if(randChoice == 1) { setHome(houseTwo); houseList.erase(houseList.begin() + randomTwo); } else if(randChoice == 2) { setHome(houseThree); houseList.erase(houseList.begin() + randomThree); } } mvwprintw(interfaceWindow, interfacePrintY-2, interfacePrintX, " "); mvwprintw(interfaceWindow, interfacePrintY-1, interfacePrintX, " "); mvwprintw(interfaceWindow, interfacePrintY, interfacePrintX, " "); mvwprintw(interfaceWindow, interfacePrintY+1, interfacePrintX, " "); wrefresh(interfaceWindow); }