mirror of
https://github.com/ra3xdh/qucs_s
synced 2025-03-28 21:13:26 +00:00
cache for graph data
This commit is contained in:
parent
e347b82810
commit
6806c1cc82
@ -431,7 +431,7 @@ void Graph::drawStarSymbols(QPainter* painter) const {
|
||||
}
|
||||
}
|
||||
|
||||
void Graph::drawLines(QPainter* painter) const {
|
||||
void Graph::drawLines(QPainter* painter) {
|
||||
painter->save();
|
||||
|
||||
QPen pen = painter->pen();
|
||||
@ -479,41 +479,48 @@ void Graph::drawLines(QPainter* painter) const {
|
||||
// - point.isGraphEnd() returns true when there is no
|
||||
// more graph data points
|
||||
|
||||
bool drawing_started = false;
|
||||
double prev_point_x = 0;
|
||||
double prev_point_y = 0;
|
||||
if (linesCache.isEmpty()) {
|
||||
|
||||
for (auto point : *this) {
|
||||
// No more data points
|
||||
if (point.isGraphEnd()) {
|
||||
break;
|
||||
}
|
||||
bool drawing_started = false;
|
||||
double prev_point_x = 0;
|
||||
double prev_point_y = 0;
|
||||
|
||||
// Subgraph has ended, let's pretend like we're
|
||||
// drawing a graph from the beginning
|
||||
if (point.isStrokeEnd()) {
|
||||
drawing_started = false;
|
||||
continue;
|
||||
}
|
||||
for (auto point : *this) {
|
||||
// No more data points
|
||||
if (point.isGraphEnd()) {
|
||||
break;
|
||||
}
|
||||
|
||||
// skip if not valid
|
||||
if (!point.isPt()) {
|
||||
continue;
|
||||
}
|
||||
// Subgraph has ended, let's pretend like we're
|
||||
// drawing a graph from the beginning
|
||||
if (point.isStrokeEnd()) {
|
||||
drawing_started = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
// First point in a subgraph. From here the drawing starts
|
||||
if (!drawing_started) {
|
||||
// skip if not valid
|
||||
if (!point.isPt()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// First point in a subgraph. From here the drawing starts
|
||||
if (!drawing_started) {
|
||||
prev_point_x = point.getScrX();
|
||||
prev_point_y = point.getScrY();
|
||||
drawing_started = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
linesCache.append(
|
||||
QLineF{prev_point_x, prev_point_y, point.getScrX(), point.getScrY()});
|
||||
|
||||
// painter->drawLine(QLineF{prev_point_x, prev_point_y, point.getScrX(), point.getScrY()});
|
||||
prev_point_x = point.getScrX();
|
||||
prev_point_y = point.getScrY();
|
||||
drawing_started = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
painter->drawLine(QLineF{prev_point_x, prev_point_y, point.getScrX(), point.getScrY()});
|
||||
prev_point_x = point.getScrX();
|
||||
prev_point_y = point.getScrY();
|
||||
}
|
||||
|
||||
painter->drawLines(linesCache);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,8 @@ public:
|
||||
typedef container::iterator iterator;
|
||||
typedef container::const_iterator const_iterator;
|
||||
|
||||
QList<QLineF> linesCache;
|
||||
|
||||
int loadDatFile(const QString& filename);
|
||||
int loadIndepVarData(const QString&, char* datfilecontent, DataX* where);
|
||||
|
||||
@ -145,8 +147,8 @@ public:
|
||||
bool isEmpty() const { return !cPointsX.size(); }
|
||||
QVector<DataX*>& mutable_axes(){return cPointsX;} // HACK
|
||||
|
||||
void clear(){ScrPoints.resize(0);}
|
||||
void resizeScrPoints(size_t s){assert(s>=ScrPoints.size()); ScrPoints.resize(s);}
|
||||
void clear(){ScrPoints.resize(0);linesCache.clear();}
|
||||
void resizeScrPoints(size_t s){assert(s>=ScrPoints.size()); ScrPoints.resize(s);linesCache.clear();}
|
||||
iterator begin(){return ScrPoints.begin();}
|
||||
iterator end(){return ScrPoints.end();}
|
||||
const_iterator begin() const{return ScrPoints.begin();}
|
||||
@ -168,7 +170,7 @@ public:
|
||||
|
||||
private: // painting
|
||||
void drawStarSymbols(QPainter* painter) const;
|
||||
void drawLines(QPainter* painter) const;
|
||||
void drawLines(QPainter* painter);
|
||||
void drawCircleSymbols(QPainter* painter) const;
|
||||
void drawArrowSymbols(QPainter* painter) const;
|
||||
public: // marker related
|
||||
@ -177,6 +179,7 @@ public: // marker related
|
||||
Diagram const* parentDiagram() const{return diagram;}
|
||||
private:
|
||||
QVector<DataX*> cPointsX;
|
||||
|
||||
std::vector<ScrPt> ScrPoints; // data in screen coordinates
|
||||
Diagram const* diagram;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user