Skip to content

Commit 961fc0f

Browse files
committed
Milestone 3 submission v2
1 parent b132776 commit 961fc0f

File tree

4 files changed

+40
-32
lines changed

4 files changed

+40
-32
lines changed

environment.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ Expression make_range(const std::vector<Expression> & args)
604604
* The built-in binary procedure apply has two arguments. The first argument
605605
* is a procedure, the second a list. It treats the elements of the list
606606
* as the arguments to the procedure, returning the result after evaluation.
607-
*/
607+
608608
Expression apply(const std::vector<Expression> & args)
609609
{
610610
//stub
@@ -615,13 +615,14 @@ Expression apply(const std::vector<Expression> & args)
615615
616616
return Expression(results);
617617
};
618+
*/
618619

619620
/*
620621
* (map <procedure> <list>)
621622
* The built-in binary procedure map is similar to apply, but treats each
622623
* entry of the list as a separate argument to the procedure, returning a
623624
* list of the same size of results.
624-
*/
625+
625626
Expression map(const std::vector<Expression> & args)
626627
{
627628
//stub
@@ -632,7 +633,7 @@ Expression map(const std::vector<Expression> & args)
632633
633634
return Expression(results);
634635
};
635-
636+
*/
636637

637638
/*
638639
* (discrete-plot DATA OPTIONS)
@@ -671,7 +672,7 @@ Expression discrete_plot(const std::vector<Expression> & args)
671672
}
672673
catch (const SemanticError & ex) {
673674
throw ex; // Re-throw error? Idk if this helps or not
674-
return EXIT_FAILURE;
675+
//return EXIT_FAILURE;
675676
}
676677
}
677678
else{

expression.cpp

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ std::vector<Expression::Point> parseData(const Expression::List & dataList, Layo
298298
Expression::List temp2 = p2.asList();
299299

300300
if ( temp1[0].isHeadNumber() && temp1[1].isHeadNumber()
301-
&& temp1[0].isHeadNumber() && temp1[1].isHeadNumber() )
301+
&& temp2[0].isHeadNumber() && temp2[1].isHeadNumber() )
302302
{
303303
double x1 = temp1[0].head().asNumber();
304304
double y1 = temp1[1].head().asNumber();
@@ -316,7 +316,7 @@ std::vector<Expression::Point> parseData(const Expression::List & dataList, Layo
316316

317317

318318
// Can now safely check any and all remaining points in data list
319-
for (auto exp : dataList) {
319+
for (auto & exp : dataList) {
320320
// Each Data entry must a List of 2 Numbers or error
321321
if (exp.isHeadList() && (exp.asList().size() == 2)) {
322322
if (exp.asList()[0].isHeadNumber() && exp.asList()[1].isHeadNumber()) {
@@ -388,7 +388,7 @@ Expression::List makeBoundBox(LayoutParams & params){
388388
// Pull struct data into local variables
389389
double xMax = params.xMax; double yMax = params.yMax;
390390
double xMin = params.xMin; double yMin = params.yMin;
391-
double xMid = params.xMid; double yMid = params.yMid;
391+
//double xMid = params.xMid; double yMid = params.yMid;
392392

393393
// Top border Line: ( (xMin, yMax) (xMax, yMax) )
394394
Expression topLine = makeLine(xMin, yMax, xMax, yMax, 0);
@@ -405,15 +405,15 @@ Expression::List makeBoundBox(LayoutParams & params){
405405
Expression::List results = { topLine, bottomLine, leftLine, rightLine };
406406

407407
// Draw X Axis?
408-
if ( (yMin < 0) && (0 < yMax) ){
409-
Expression xAxisLine = makeLine(xMin, yMid, xMax, yMid, 0);
408+
if ( (yMin < 0) && (0 < yMax) ){
409+
Expression xAxisLine = makeLine(xMin, 0, xMax, 0, 0);
410410
results.push_back(xAxisLine);
411411
params.xAxis = true;
412412
}
413413

414414
// Draw Y Axis?
415415
if ( (xMin < 0) && (0 < xMax) ){
416-
Expression yAxisLine = makeLine(xMid, yMin, xMid, yMax, 0);
416+
Expression yAxisLine = makeLine(0, yMin, 0, yMax, 0);
417417
results.push_back(yAxisLine);
418418
params.yAxis = true;
419419
}
@@ -531,27 +531,31 @@ Expression::List processOptions(const Expression::List & options, const LayoutPa
531531
return results;
532532
};
533533

534-
Expression::List makeTickLabels(const LayoutParams & params){
534+
Expression::List makeTickLabels(const LayoutParams & oldParams, const LayoutParams & newParams){
535535

536536
// Pull struct data into local variables
537-
double xMax = params.xMax; double yMax = params.yMax;
538-
double xMin = params.xMin; double yMin = params.yMin;
539-
double xOff = params.D; double yOff = params.C;
537+
double xMax = newParams.xMax; double yMax = newParams.yMax;
538+
double xMin = newParams.xMin; double yMin = newParams.yMin;
539+
double xOff = newParams.D; double yOff = newParams.C;
540540

541-
double scale = params.txtScale;
541+
double scale = newParams.txtScale;
542542

543-
std::ostringstream outStream;
544-
outStream << "\"" << std::setprecision(2) << xMax << "\"";
545-
std::string xTop = outStream.str();
543+
// Label values should be unscaled input values, but use scaled values for placing
544+
std::ostringstream outStream1;
545+
outStream1 << std::setprecision(2) << oldParams.xMax;
546+
std::string xTop = outStream1.str();
546547

547-
outStream << "\"" << std::setprecision(2) << xMin << "\"";
548-
std::string xBot = outStream.str();
548+
std::ostringstream outStream2;
549+
outStream2 << std::setprecision(2) << oldParams.xMin;
550+
std::string xBot = outStream2.str();
549551

550-
outStream << "\"" << std::setprecision(2) << yMax << "\"";
551-
std::string yRight = outStream.str();
552+
std::ostringstream outStream3;
553+
outStream3 << std::setprecision(2) << oldParams.yMax;
554+
std::string yRight = outStream3.str();
552555

553-
outStream << "\"" << std::setprecision(2) << yMin << "\"";
554-
std::string yLeft = outStream.str();
556+
std::ostringstream outStream4;
557+
outStream4 << std::setprecision(2) << oldParams.yMin;
558+
std::string yLeft = outStream4.str();
555559

556560
Expression xTopLabel = makeText(xTop, xMin - xOff, yMax, scale, 0.0);
557561
Expression xBottomLabel = makeText(xBot, xMin - xOff, yMin, scale, 0.0);
@@ -656,7 +660,7 @@ Expression::List Expression::makeDiscretePlot(const List & data, const List & op
656660
}
657661

658662
/*--- Make the Tick Mark Text Labels ---*/
659-
List labels = makeTickLabels(outParams);
663+
List labels = makeTickLabels(params, outParams);
660664
for (auto & item : labels) {
661665
results.push_back(item);
662666
}

output_widget.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void OutputWidget::getResult(Settings result){
5151
m_item = nullptr;
5252

5353
// Draw cosmetic lines at scene origin for visual reference
54-
//drawCrosshairs();
54+
drawCrosshairs();
5555

5656
// Display new graphic item
5757
if(result.itemType != Settings::Type::None_Type){
@@ -173,14 +173,17 @@ void OutputWidget::drawCrosshairs(){
173173

174174
QPen p;
175175
p.setWidth(0);
176+
177+
double scale = 1;
176178

177-
m_scene->addLine(QLineF(QPoint(-10, 0), QPoint(10, 0)), p);
178-
m_scene->addLine(QLineF(QPoint( 0,-10), QPoint(0, 10)), p);
179+
m_scene->addLine(QLineF(QPoint(-1 * scale, 0), QPoint(1 * scale, 0)), p);
180+
m_scene->addLine(QLineF(QPoint( 0, -1 * scale), QPoint(0, 1 * scale)), p);
179181
}
180182

181183
void OutputWidget::resizeEvent(QResizeEvent * event){
182-
184+
183185
// Automatically re-focus the view when widget is resized
184186
m_view->fitInView(m_scene->itemsBoundingRect(), Qt::KeepAspectRatio);
187+
event->accept();
185188
}
186189

settings.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ struct Settings {
2323
double scale; // used when type is Text_Type
2424
double rotate;// used when type is Text_Type
2525
double size; // used when type is Point_Type
26-
double thicc; // used when type is Line_Type
27-
QPoint p1;
28-
QPoint p2;
26+
QPoint p1; // used when type is Line_Type
27+
QPoint p2; // used when type is Line_Type
28+
double thicc; // used when type is Line_Type
2929

3030
// constructors for use in assignment, signal, and output
3131
Settings() {};

0 commit comments

Comments
 (0)