Skip to content

Commit

Permalink
Merge pull request #79 from afei190/master
Browse files Browse the repository at this point in the history
Add functions to set x and y limits manually for SimFigure
  • Loading branch information
pmackenz authored Aug 5, 2020
2 parents 83ae914 + 231a2cd commit 7185c35
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
46 changes: 45 additions & 1 deletion SimFigure/source/simfigure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,21 @@ void SimFigure::rescale(void)
m_plot->setAxisScale(QwtPlot::yLeft, 1, 100);
m_plot->setAxisScale(QwtPlot::xBottom, 1, 100);
}

}

/*! set limits for x axis (private) */
void SimFigure::setXLim(double xmin, double xmax)
{
m_plot->setAxisScale(QwtPlot::xBottom, xmin, xmax);
m_plot->replot();
}

/*! set limits for y axis (private) */
void SimFigure::setYLim(double ymin, double ymax)
{
m_plot->setAxisScale(QwtPlot::yLeft, ymin, ymax);
m_plot->replot();
}

/*! Regenerate th egrid with new settings (Type, limits) - (private) */
Expand Down Expand Up @@ -912,7 +927,36 @@ void SimFigure::setLineStyle(QwtPlotCurve *curve, LineType lt)
*/
SimFigure::Marker SimFigure::marker(int ID)
{

if (ID > 0 && m_curves.length() <= ID && m_curves.value(ID-1) != nullptr)
{
const QwtSymbol *sym = m_curves.value(ID-1)->symbol();
int mk = sym->style();
switch (mk) {
case QwtSymbol::NoSymbol:
return Marker::None;
case QwtSymbol::XCross:
return Marker::Ex;
case QwtSymbol::Rect:
return Marker::Box;
case QwtSymbol::Cross:
return Marker::Plus;
case QwtSymbol::Ellipse:
return Marker::Circle;
case QwtSymbol::Star1:
return Marker::Asterisk;
case QwtSymbol::Triangle:
return Marker::Triangle;
case QwtSymbol::DTriangle:
return Marker::DownTriangle;
case QwtSymbol::LTriangle:
return Marker::LeftTriangle;
case QwtSymbol::RTriangle:
return Marker::RightTriangle;
}
}
else {
return Marker::None;
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions SimFigure/source/simfigure.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class SimFigure : public QFrame
int plot(QVector<double> &, QVector<double> &, LineType lt = LineType::Solid, QColor col = Qt::red, Marker mk = Marker::None);
int scatter(QVector<double> &, QVector<double> &, QColor col = Qt::blue, Marker mk = Marker::Circle);


void clear(void);
void cla(void);

Expand All @@ -136,6 +137,8 @@ class SimFigure : public QFrame

void setXLabel(QString lbl);
void setYLabel(QString lbl);
void setXLim(double xmin, double xmax);
void setYLim(double ymin, double ymax);
void setLabelFontSize(int);
void setTitle(QString title);
void setTitleFontSize(int);
Expand Down

0 comments on commit 7185c35

Please sign in to comment.