Skip to content

Commit

Permalink
Marker notation follows diagram number notation #383
Browse files Browse the repository at this point in the history
  • Loading branch information
ra3xdh committed Dec 1, 2023
1 parent b5921f2 commit 06a82a1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
14 changes: 12 additions & 2 deletions qucs/diagrams/marker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,14 @@ void Marker::createText()
pz[1] = VarDep[1];

// now actually create text.
bool engNotation = pGraph->parentDiagram()->engineeringNotation;
for(unsigned ii=0; (pD=pGraph->axis(ii)); ++ii) {
Text += pD->Var + ": " + QString::number(VarPos[ii],'g',Precision) + "\n";
Text += pD->Var + ": ";
if (engNotation) {
Text += misc::num2str(VarPos[ii],Precision) + "\n";
} else {
Text += QString::number(VarPos[ii],'g',Precision) + "\n";
}
}

Text += pGraph->Var + ": ";
Expand All @@ -230,7 +236,11 @@ void Marker::createText()
} else {
double mag = sqrt(pz[0]*pz[0] + pz[1]*pz[1]);
double val = qucs::num2db(mag,ax->Units);
Text += QString::number(val,'g',Precision);
if (engNotation) {
Text += misc::num2str(val,Precision) + "\n";
} else {
Text += QString::number(val,'g',Precision);
}
}

assert(diag());
Expand Down
10 changes: 8 additions & 2 deletions qucs/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void misc::str2num(const QString& s_, double& Number, QString& Unit, double& Fac
}

// #########################################################################
QString misc::num2str(double Num)
QString misc::num2str(double Num, int Precision)
{
char c = 0;
double cal = fabs(Num);
Expand All @@ -295,7 +295,13 @@ QString misc::num2str(double Num)
if(c) Num /= pow(10.0, double(3*Expo));
}

QString Str = QString::number(Num);
QString Str;
if (Precision == -1) {
Str = QString::number(Num);
} else {
Str = QString::number(Num,'f',Precision);
}

if(c) Str += c;

return Str;
Expand Down
2 changes: 1 addition & 1 deletion qucs/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace misc {
QString complexRad (double, double, int Precision=3);
QString StringNum (double, char form='g', int Precision=3);
void str2num (const QString&, double&, QString&, double&);
QString num2str (double);
QString num2str (double, int Precision = -1);
QColor ColorFromString(const QString& color);
QString StringNiceNum(double);
void convert2Unicode(QString&);
Expand Down

0 comments on commit 06a82a1

Please sign in to comment.