Skip to content

Commit 7185c35

Browse files
authored
Merge pull request #79 from afei190/master
Add functions to set x and y limits manually for SimFigure
2 parents 83ae914 + 231a2cd commit 7185c35

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

SimFigure/source/simfigure.cpp

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,21 @@ void SimFigure::rescale(void)
389389
m_plot->setAxisScale(QwtPlot::yLeft, 1, 100);
390390
m_plot->setAxisScale(QwtPlot::xBottom, 1, 100);
391391
}
392+
393+
}
394+
395+
/*! set limits for x axis (private) */
396+
void SimFigure::setXLim(double xmin, double xmax)
397+
{
398+
m_plot->setAxisScale(QwtPlot::xBottom, xmin, xmax);
399+
m_plot->replot();
400+
}
401+
402+
/*! set limits for y axis (private) */
403+
void SimFigure::setYLim(double ymin, double ymax)
404+
{
405+
m_plot->setAxisScale(QwtPlot::yLeft, ymin, ymax);
406+
m_plot->replot();
392407
}
393408

394409
/*! Regenerate th egrid with new settings (Type, limits) - (private) */
@@ -912,7 +927,36 @@ void SimFigure::setLineStyle(QwtPlotCurve *curve, LineType lt)
912927
*/
913928
SimFigure::Marker SimFigure::marker(int ID)
914929
{
915-
930+
if (ID > 0 && m_curves.length() <= ID && m_curves.value(ID-1) != nullptr)
931+
{
932+
const QwtSymbol *sym = m_curves.value(ID-1)->symbol();
933+
int mk = sym->style();
934+
switch (mk) {
935+
case QwtSymbol::NoSymbol:
936+
return Marker::None;
937+
case QwtSymbol::XCross:
938+
return Marker::Ex;
939+
case QwtSymbol::Rect:
940+
return Marker::Box;
941+
case QwtSymbol::Cross:
942+
return Marker::Plus;
943+
case QwtSymbol::Ellipse:
944+
return Marker::Circle;
945+
case QwtSymbol::Star1:
946+
return Marker::Asterisk;
947+
case QwtSymbol::Triangle:
948+
return Marker::Triangle;
949+
case QwtSymbol::DTriangle:
950+
return Marker::DownTriangle;
951+
case QwtSymbol::LTriangle:
952+
return Marker::LeftTriangle;
953+
case QwtSymbol::RTriangle:
954+
return Marker::RightTriangle;
955+
}
956+
}
957+
else {
958+
return Marker::None;
959+
}
916960
}
917961

918962
/**

SimFigure/source/simfigure.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class SimFigure : public QFrame
112112
int plot(QVector<double> &, QVector<double> &, LineType lt = LineType::Solid, QColor col = Qt::red, Marker mk = Marker::None);
113113
int scatter(QVector<double> &, QVector<double> &, QColor col = Qt::blue, Marker mk = Marker::Circle);
114114

115+
115116
void clear(void);
116117
void cla(void);
117118

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

137138
void setXLabel(QString lbl);
138139
void setYLabel(QString lbl);
140+
void setXLim(double xmin, double xmax);
141+
void setYLim(double ymin, double ymax);
139142
void setLabelFontSize(int);
140143
void setTitle(QString title);
141144
void setTitleFontSize(int);

0 commit comments

Comments
 (0)