@@ -255,71 +255,46 @@ void MainWindow::do_loadFile()
255255 }
256256 inputFile.setFileName (ui->lineEdit_filePath ->text ());
257257 inputFile.open (QIODevice::ReadOnly);
258- items .clear ();
258+ objList .clear ();
259259 ui->textBrowser_read ->clear ();
260- // while (!inputFile.atEnd())
261- // {
262- // QString buffer = "";
263- // char tmp = 0;
264- // while (tmp != ';' && !inputFile.atEnd())
265- // {
266- // inputFile.read(&tmp, 1);
267- // buffer += tmp;
268- // }
269- // if (buffer.endsWith(";"))
270- // {
271- // hpgl_cmd aparser = hpgl_cmd(buffer);
272- // cmdList.append(aparser);
273- // ui->textBrowser_read->append(cmdList.last().print());
274- // }
275- // }
276260
277261 QString buffer = " " ;
278262 QTextStream fstream (&inputFile);
279263 buffer = fstream.readAll ();
280-
264+ objList. push_back ( hpgl_obj (buffer));
281265
282266 // Set up new graphics view.
283267
268+ QPen downPen;
269+ QPen upPen;
270+
271+ downPen.setColor (QColor (0 , 0 , 255 ));
272+ downPen.setWidth (2 );
273+ downPen.setJoinStyle (Qt::RoundJoin);
274+
275+ upPen.setStyle (Qt::DotLine);
276+ upPen.setWidth (2 );
277+ upPen.setColor (QColor (200 , 100 , 100 ));
278+
284279 plotScene.clear ();
285280
286- // int curX, curY;
287- // for (int i = 0; i < cmdList.count(); i++)
288- // {
289- // if (cmdList.at(i)[0] == 'P' && cmdList.at(i)[1] == 'D')
290- // {
291- // ui->textBrowser_console->append("Found PD: " + cmdList.at(i));
292- // int charIndex = 1;
293- // int nextX, nextY;
294- // while (cmdList.at(i)[charIndex] != ';')
295- // {
296- // charIndex++;
297- // nextX = get_nextInt(cmdList.at(i), &charIndex);
298- // charIndex++;
299- // nextY = get_nextInt(cmdList.at(i), &charIndex);
300-
301- // plotScene.addLine(curX, -curY, nextX, -nextY);
302- // ui->textBrowser_console->append(timeStamp() + "Adding line [" +
303- // QString::number(curX) + "," + QString::number(curY) +
304- // "] to [" + QString::number(nextX) + "," +
305- // QString::number(nextY) + "].");
306- // curX = nextX;
307- // curY = nextY;
308- // }
309- // }
310- // else if (cmdList.at(i)[0] == 'P' && cmdList.at(i)[1] == 'U')
311- // {
312- // ui->textBrowser_console->append("Found PU: " + cmdList.at(i));
313- // int charIndex = 1;
314- // while (cmdList.at(i)[charIndex] != ';')
315- // {
316- // charIndex++;
317- // curX = get_nextInt(cmdList.at(i), &charIndex);
318- // charIndex++;
319- // curY = get_nextInt(cmdList.at(i), &charIndex);
320- // }
321- // }
322- // }
281+ QList<QLine> lines_down;
282+ lines_down.clear ();
283+ QList<QLine> lines_up;
284+ lines_up.clear ();
285+ for (int i = 0 ; i < objList.length (); i++)
286+ {
287+ lines_down = objList[i].line_list_down ();
288+ lines_up = objList[i].line_list_up ();
289+ for (int l = 0 ; l < lines_down.length (); l++)
290+ {
291+ plotScene.addLine (lines_down[l], downPen);
292+ }
293+ for (int l = 0 ; l < lines_up.length (); l++)
294+ {
295+ plotScene.addLine (lines_up[l], upPen);
296+ }
297+ }
323298
324299 ui->graphicsView_view ->setSceneRect (plotScene.sceneRect ());
325300 ui->graphicsView_view ->show ();
@@ -330,9 +305,9 @@ void MainWindow::do_plot()
330305 qDebug () << " Plotting file!" ;
331306 if (serialBuffer.isNull ())
332307 {
333- for (int i = 0 ; i < items .count (); i++)
308+ for (int i = 0 ; i < objList .count (); i++)
334309 {
335- hpgl_obj obj = items .at (i);
310+ hpgl_obj obj = objList .at (i);
336311 int size = obj.printLen ();
337312// for (int d = 0; d < size; d++)
338313// {
@@ -341,14 +316,14 @@ void MainWindow::do_plot()
341316 }
342317 return ;
343318 }
344- if (!serialBuffer->isOpen () || items .isEmpty ())
319+ if (!serialBuffer->isOpen () || objList .isEmpty ())
345320 {
346321 ui->textBrowser_console ->append (timeStamp () + " Can't plot!" );
347322 return ;
348323 }
349- for (int i = 0 ; i < items .count (); i++)
324+ for (int i = 0 ; i < objList .count (); i++)
350325 {
351- hpgl_obj obj = items .at (i);
326+ hpgl_obj obj = objList .at (i);
352327 int size = obj.printLen ();
353328 QString printThis = obj.print ();
354329// serialBuffer->write(cmdList.at(i).toStdString().c_str(), size);
0 commit comments