2016-07-22 5 views
0

I subclassed QwtPlot mag:QwtPlot setAxisScale, wie es funktioniert?

class RealPlot : public QwtPlot { 
public: 
    RealPlot() { 
     ... 
     setAxisScale(QwtPlot::xBottom, -5, 5); 
    } 
    void addPoint(Point p) { 
     ... 
     setAxisScale(QwtPlot::xBottom, min, max); 
    } 
} 

Und ich möchte die (horizontale Achse) Plot ein neuer Punkt hinzugefügt wird jedes Mal neu zu skalieren. Also rufe ich setAxisScale(QwtPlot::xBottom, min, max); kurz nachdem der Punkt zur Kurve hinzugefügt wurde.

Das Problem ist, dass das Diagramm nicht neu skaliert wird. Der Aufruf von setAxisScale(QwtPlot::xBottom, -5, 5); im Konstruktor skaliert das Diagramm neu. Aber setAxisScale(QwtPlot::xBottom, min, max); nicht. Warum?

Antwort

1

QwtPlot :: replot fehlt, um Ihre Änderungen zuzulassen. Im Falle eines Starts kommt es immer zu einem ersten Replot - deshalb arbeitet es dort.