Skip to content

Commit

Permalink
Merge pull request #897 from ra3xdh/892_fix
Browse files Browse the repository at this point in the history
Point type graph redering fix
  • Loading branch information
ra3xdh authored Aug 20, 2024
2 parents c79dc61 + 2b5b7d4 commit 07f3cc1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
24 changes: 14 additions & 10 deletions qucs/diagrams/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,27 +293,27 @@ std::pair<double,double> Graph::findSample(std::vector<double>& VarPos) const

// -----------------------------------------------------------------------
// meaning of the values in a graph "Points" list
#define STROKEEND -2
#define BRANCHEND -10
#define GRAPHEND -100
//#define STROKEEND -2
//#define BRANCHEND -10
//#define GRAPHEND -100
// -----------------------------------------------------------------------
// screen points pseudo iterator implementation.
void Graph::ScrPt::setStrokeEnd()
{
ScrX = STROKEEND;
type = STROKEEND;
}
void Graph::ScrPt::setBranchEnd()
{
ScrX = BRANCHEND;
type = BRANCHEND;
}
void Graph::ScrPt::setGraphEnd()
{
ScrX = GRAPHEND;
type = GRAPHEND;
}
bool Graph::ScrPt::isPt() const{return ScrX>=0.;}
bool Graph::ScrPt::isStrokeEnd() const{return ScrX<=STROKEEND;}
bool Graph::ScrPt::isBranchEnd() const{return ScrX<=BRANCHEND;}
bool Graph::ScrPt::isGraphEnd() const{return ScrX<=GRAPHEND;}
bool Graph::ScrPt::isPt() const{return (ScrX >= 0. && type == DataPt);}
bool Graph::ScrPt::isStrokeEnd() const{return (type >= STROKEEND);}
bool Graph::ScrPt::isBranchEnd() const{return (type >= BRANCHEND);}
bool Graph::ScrPt::isGraphEnd() const{return (type >= GRAPHEND);}

/*!
* set screen coordinate for graph sampling point
Expand All @@ -324,6 +324,8 @@ bool Graph::ScrPt::isGraphEnd() const{return ScrX<=GRAPHEND;}
void Graph::ScrPt::setScrX(float x) {
if (x < 0) {
qDebug() << "dangerous: negative screen coordinate" << x;
} else {
type = DataPt;
}
if (ScrX < 0) {
qDebug() << "dangerous: (maybe) overwriting control token" << x;
Expand All @@ -334,6 +336,8 @@ void Graph::ScrPt::setScrX(float x) {
void Graph::ScrPt::setScrY(float y) {
if (y < 0) { // need to investigate...
qDebug() << "setting negative screen coordinate" << y << "at" << ScrY;
} else {
type = DataPt;
}
ScrY = y;
}
Expand Down
8 changes: 7 additions & 1 deletion qucs/diagrams/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,20 @@ class Graph : public Element {
Graph(const Diagram*, const QString& _Line="");
~Graph();

enum PtType { NotDrawn = 0, DataPt = 1, STROKEEND = 2, BRANCHEND = 3, GRAPHEND = 4};

class ScrPt{
private:
float ScrX;
float ScrY;
PtType type;

double indep; // top level indep value (sweep)
double dep; // top level dep value // FIXME: type?!
public:
ScrPt() : ScrX(0){}
ScrPt() { ScrX = 0; ScrY = 0;
type = NotDrawn;
dep = 0.0; indep = 0.0; }
~ScrPt(){}

void setStrokeEnd();
Expand Down

0 comments on commit 07f3cc1

Please sign in to comment.