~jeremyrcohen/+junk/Interpreter

« back to all changes in this revision

Viewing changes to software/FabInterpreter/mainwindow.cpp

  • Committer: Jeremy Cohen
  • Date: 2010-08-04 18:47:29 UTC
  • Revision ID: jeremyrcohen@gmail.com-20100804184729-uizqzcs1te40ixzj
reversed axes and fixed glitches in dealing with multiple config files, close button does fully work yet though

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
 
71
71
void MainWindow::initializePrinter()
72
72
{
73
 
    //NOTE: for every connect added here you must add a disconnect!!!
 
73
    //NOTE: for every connect added here you must add a disconnect to the slot
74
74
    printer = new FabAtHomePrinter();
75
75
    pThread = new PrintThread(printer);
76
76
    gcThread = new GUIComponentsThread();
88
88
 
89
89
void MainWindow::disconnectPrinterFunctions()
90
90
{
 
91
    /*
91
92
    disconnect(PauseFabButton, SIGNAL(clicked()), printer, SLOT(pausePrint()));
92
93
    disconnect(CancelFabButton, SIGNAL(clicked()), printer, SLOT(cancelPrint()));
93
94
    disconnect(RedoPathButton, SIGNAL(clicked()), printer, SLOT(redoPath()));
97
98
    disconnect(printer, SIGNAL(callWarning(QString)), this, SLOT(callWarning(QString)));
98
99
    disconnect(printer, SIGNAL(reportProgress(int, QString)), this, SLOT(printer_reportProgress(int, QString)));
99
100
    disconnect(printer, SIGNAL(finishedPrinting()), this, SLOT(resetValues()));
 
101
    disconnect(DeletePrinterConfig, SIGNAL(clicked()), gcThread, SLOT(disablePositionDisplay()));
 
102
    */
 
103
    disconnect(printer, 0, 0, 0);
 
104
    disconnect(gcThread, 0, 0, 0);
 
105
    disconnect(printer, SLOT(cancelPrint()));
 
106
    disconnect(printer, SLOT(deleteLater()));
 
107
    disconnect(printer, SLOT(pausePrint()));
 
108
    disconnect(printer, SLOT(redoPath()));
 
109
    disconnect(printer, SLOT(resetPos()));
 
110
    disconnect(printer, SLOT(stopMotors()));
 
111
    disconnect(gcThread, SLOT(disablePositionDisplay()));
100
112
    if (gcThread != NULL)
101
113
    {
102
114
        gcThread->disablePositionDisplay();
105
117
    }
106
118
    if (pThread != NULL)
107
119
    {
108
 
        pThread->stopThread();
109
 
        while (pThread->isRunning());
110
120
        delete pThread;
111
121
    }
112
 
    if (printer != NULL && printer->isInitialized())
 
122
    if (printer != NULL)
113
123
    {
114
124
        previousPrinter = printer;
115
 
        printer->cancelPrint();
116
 
        while (!printer->cleanUp());
 
125
        if (printer->isInitialized())
 
126
            while (!printer->cleanUp());
117
127
        delete printer;
118
128
    }
119
129
}
129
139
    //Open file dialog
130
140
    QString str = QFileDialog::getOpenFileName(this,"Config File Loader", "/Users/jcman912/Documents/Fab@Home/Interpreter_Experimental/software", "*.config");
131
141
 
132
 
    if (initialized)
133
 
        reconnectPrinterFunctions();
134
 
    else
135
 
    {
136
 
        initializePrinter();
 
142
    if (!initialized)
137
143
        initialized = true;
138
 
    }
 
144
    initializePrinter();
139
145
    string result = printer->initialize(str.toStdString(), PortName->text().toStdString());
140
146
    if(result.compare("") == 0)
141
147
    {
199
205
        callWarning(result.c_str());
200
206
    }
201
207
 
202
 
    if (str == NULL)
203
 
        printf("HI");
204
208
    previousPrinter = printer;
205
209
 
206
210
}
358
362
    if(numLoadedBays >= 1)
359
363
    {
360
364
        temp = Util::toString<double>(printer->tool.bays["Bay 0"].motor->getPosition());
 
365
        bayMotorPosition0->setText(temp.c_str());
361
366
    }
362
367
    if(numLoadedBays >= 2)
363
368
    {
468
473
        ForceStopButton->setEnabled(false);
469
474
        RedoPathButton->setEnabled(false);
470
475
        LoadConfigButton->setEnabled(true);
 
476
        XLabel->setText("Not Loaded");
 
477
        YLabel->setText("Not Loaded");
 
478
        ZLabel->setText("Not Loaded");
 
479
        bayLabel0->setText("Not Loaded");
 
480
        bayLabel1->setText("Not Loaded");
 
481
        bayLabel2->setText("Not Loaded");
 
482
        resetValues();
 
483
        if (printer->isInitialized())
 
484
            printer->resetPos();
 
485
        disconnectPrinterFunctions();
471
486
    }
472
487
}
473
488