Skip to content

Commit

Permalink
Removed phasordiagram and waveac from the build system
Browse files Browse the repository at this point in the history
The aim of this commit is to put aside the waveac and phasordiagram
code. This code is becoming a problem to merge older PR and entagles
(even more) the Qucs code. In this sense, phasordiagram.h/.cpp and
waveac.h/.cpp were removed from "CMakeLists.txt" and "Makefile.am". The
most relevant code spread over diagram.cpp/h, marker.cpp/h, etc. was
commented. On the other hand, those portions of code that intrudes
existing functions were removed since it'll be needed to figure out a
non-intrusive way to implement that feature.
  • Loading branch information
andresmmera committed Dec 16, 2017
1 parent 4dc65b9 commit 8d1a894
Show file tree
Hide file tree
Showing 12 changed files with 93 additions and 316 deletions.
8 changes: 5 additions & 3 deletions qucs/qucs/diagrams/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ diagrams.h
graph.h
marker.h
markerdialog.h
phasordiagram.h
polardiagram.h
psdiagram.h
rect3ddiagram.h
Expand All @@ -22,14 +21,17 @@ smithdiagram.h
tabdiagram.h
timingdiagram.h
truthdiagram.h
waveac.h
#phasordiagram.h
#waveac.h
)

SET(DIAGRAMS_SRCS
curvediagram.cpp graph.cpp polardiagram.cpp smithdiagram.cpp
diagram.cpp marker.cpp psdiagram.cpp tabdiagram.cpp
diagramdialog.cpp markerdialog.cpp rect3ddiagram.cpp timingdiagram.cpp
rectdiagram.cpp phasordiagram.cpp truthdiagram.cpp waveac.cpp
rectdiagram.cpp truthdiagram.cpp
#phasordiagram.cpp
#waveac.cpp
)

SET(DIAGRAMS_MOC_HDRS
Expand Down
6 changes: 4 additions & 2 deletions qucs/qucs/diagrams/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ MOCFILES = $(MOCHEADERS:.h=.moc.cpp)
libdiagrams_la_SOURCES = tabdiagram.cpp smithdiagram.cpp rectdiagram.cpp \
polardiagram.cpp graph.cpp diagramdialog.cpp diagram.cpp marker.cpp \
markerdialog.cpp psdiagram.cpp rect3ddiagram.cpp curvediagram.cpp \
timingdiagram.cpp truthdiagram.cpp phasordiagram.cpp waveac.cpp
timingdiagram.cpp truthdiagram.cpp
# phasordiagram.cpp waveac.cpp

nodist_libdiagrams_la_SOURCES = $(MOCFILES)

noinst_HEADERS = $(MOCHEADERS) diagram.h graph.h polardiagram.h rectdiagram.h \
smithdiagram.h tabdiagram.h diagrams.h marker.h psdiagram.h rect3ddiagram.h \
curvediagram.h timingdiagram.h truthdiagram.h phasordiagram.h waveac.h
curvediagram.h timingdiagram.h truthdiagram.h
#phasordiagram.h waveac.h

AM_CPPFLAGS = $(X11_INCLUDES) $(QT_INCLUDES) -I$(top_srcdir)/qucs

Expand Down
176 changes: 23 additions & 153 deletions qucs/qucs/diagrams/diagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ Diagram::Diagram(int _cx, int _cy)
xAxis.limit_max = yAxis.limit_max = zAxis.limit_max = 1.0;
xAxis.step = yAxis.step = zAxis.step = 1.0;
xAxis.autoScale = yAxis.autoScale = zAxis.autoScale = true;

/* CODE RELATED TO THE PHASOR DIAGRAM
//used in phasor diagram, scales for Volts, Ampere, Watts and Ohms
xAxisI = xAxisV = xAxisP = xAxisZ = xAxis;
yAxisI = yAxisV = yAxisP = yAxisZ = yAxis;
zAxisI = zAxisV = zAxisP = zAxisZ = zAxis;
zAxisI = zAxisV = zAxisP = zAxisZ = zAxis;*/

rotX = 315; // for 3D diagram
rotY = 0;
Expand Down Expand Up @@ -119,11 +121,6 @@ void Diagram::paintDiagram(ViewPainter *p)
// draw all graphs
foreach(Graph *pg, Graphs)
{
if(Name=="Phasor")//phasor diagram uses another way to draw
{
pg->paintvect(p, cx, cy);
}
else
pg->paint(p, cx, cy);
}
// keep track of painter state
Expand Down Expand Up @@ -195,12 +192,10 @@ void Diagram::createAxisLabels()
if(xAxis.Label.isEmpty()) {
// write all x labels ----------------------------------------
foreach(Graph *pg, Graphs) {
if(Name != "Phasor")
{
DataX const *pD = pg->axis(0);
if(!pD) continue;
y -= LineSpacing;
if(Name[0] != 'C' && Name != "Waveac") { // locus curve ?
if(Name[0] != 'C') { // locus curve ?
w = metrics.width(pD->Var) >> 1;
if(w > wmax) wmax = w;
Texts.append(new Text(x-w, y, pD->Var, pg->Color, 12.0));
Expand All @@ -211,54 +206,6 @@ void Diagram::createAxisLabels()
Texts.append(new Text(x-w, y, "real("+pg->Var+")",
pg->Color, 12.0));
}
if(Name == "Waveac")
{
if(y == -y1 - LineSpacing)
{
w = metrics.width("Frequency: " + sfreq) >> 1;
if(w > wmax) wmax = w;
Texts.append(new Text(x-w, y, "Frequency - " + sfreq, Qt::black, 12.0));
y -= LineSpacing;
}
w = metrics.width("Time") >> 1;
if(w > wmax) wmax = w;
Texts.append(new Text(x-w, y, "Time", pg->Color, 12.0));
}
}
//phasor diagram will show the frequency that is working and the names and value
//of the display vectors below of the diagram
else
{
if(pg->yAxisNo != 0) continue;
if(pg->cPointsY) {
y -= LineSpacing;
if(y == -y1 - LineSpacing)
{
w = metrics.width("Frequency: " + sfreq) >> 1;
if(w > wmax) wmax = w;
Texts.append(new Text(x-w, y, "Frequency - " + sfreq, Qt::black, 12.0));
y -= LineSpacing;
}
nfreqa=0;
if(!findmatch(pg,0) || (pg->countY) > 1 || nfreqt>1)
{
w = metrics.width(pg->Var) >> 1;
if(w > wmax) wmax = w;
Texts.append(new Text(x-w, y, pg->Var, pg->Color, 12.0));
}
else
{
double *pz;
findmatch(pg,0);
pz = pg->gy;
Str = misc::complexDeg (*pz, *(pz+1), pg->Precision);
w = metrics.width(pg->Var+" - "+Str) >> 1;
if(w > wmax) wmax = w;
Texts.append(new Text(x-w, y, pg->Var+" - "+Str,
pg->Color, 12.0));
}
}
}
}
}
else {
Expand All @@ -283,7 +230,6 @@ void Diagram::createAxisLabels()
foreach(Graph *pg, Graphs) {
if(pg->yAxisNo != 0) continue;
if(pg->cPointsY) {
if(Name == "Phasor") continue;
if(Name[0] != 'C') { // location curve ?
w = metrics.width(pg->Var) >> 1;
if(w > wmax) wmax = w;
Expand Down Expand Up @@ -322,7 +268,6 @@ void Diagram::createAxisLabels()
foreach(Graph *pg, Graphs) {
if(pg->yAxisNo != 1) continue;
if(pg->cPointsY) {
if(Name == "Phasor") continue;
if(Name[0] != 'C') { // location curve ?
w = metrics.width(pg->Var) >> 1;
if(w > wmax) wmax = w;
Expand Down Expand Up @@ -695,7 +640,7 @@ void Diagram::getAxisLimits(Graph *pg)
DataX const *pD = pg->axis(0);
if(pD == 0) return;

if(Name[0] != 'C' && Name != "Phasor" && Name != "Waveac") { // not for location curves
if(Name[0] != 'C') { // not for location curves
p = pD->Points;
for(z=pD->count; z>0; z--) { // check x coordinates (1. dimension)
x = *(p++);
Expand Down Expand Up @@ -726,74 +671,6 @@ void Diagram::getAxisLimits(Graph *pg)
(pa->numGraphs)++; // count graphs
p = pg->cPointsY;
if(p == 0) return; // if no data => invalid
//phasor diagram and waveac have different ways to determing the limits
if(Name == "Phasor" || Name == "Waveac")
{ //find what type is the graph(voltage,current,electric power or electrical impedance)
findaxisA(pg);
if(pg->yAxisNo == 0) pA = yAxisA;
else pA = zAxisA;
nfreqt=0;
findfreq(pg);
if(Name == "Waveac")
{
nfreqa=0;
for(z=0;z<pg->countY; z++) { // every branch of curves
if(!findmatch(pg,z)) break;
p=pg->gy;

x = *(p++);
y = *(p++);
x = sqrt(x*x+y*y);
if(std::isfinite(x)) {
if(fabs(x) > pa->max) pa->max = fabs(x);
pa->min = -pa->max;
}
if(freq[0]>0)
xAxis.max = 1.0/freq[0];
else
xAxis.max = 1.0;

xAxis.min = 0.0;
}
return;
}
//if the frequency writen is in the ac simulation it will analyse the global limits
//and the limits for that type
for(i=0;i<nfreqt;i++)
{
nfreqa=i;
//for(z=pg->countY*pD->count; z>0; z--) {
for(z=0;z<pg->countY; z++) { // every branch of curves
if(!findmatch(pg,z)) break;
p=pg->gy;

x = *(p++);
y = *(p++);
if(Name == "Phasor")
{
if(std::isfinite(x)) {
if(x > xAxisA->max) xAxisA->max = x;
if(x < xAxisA->min) xAxisA->min = x;
if(x > xAxis.max) xAxis.max = x;
if(x < xAxis.min) xAxis.min = x;
}
if(std::isfinite(y)) {
if(y > pA->max) pA->max = y;
if(y < pA->min) pA->min = y;
if(y > pa->max) pa->max = y;
if(y < pa->min) pa->min = y;
}
}
}
if(Name == "Phasor")
{
setlimitsphasor(&xAxis,pa);
setlimitsphasor(xAxisA,pA);

}
}
return;
}
for(z=pg->countY*pD->count; z>0; z--) { // check every y coordinate
x = *(p++);
y = *(p++);
Expand Down Expand Up @@ -830,9 +707,6 @@ void Diagram::loadGraphData(const QString& defaultDataSet)
yAxis.min = zAxis.min = xAxis.min = DBL_MAX;
yAxis.max = zAxis.max = xAxis.max = -DBL_MAX;

if(Name == "Phasor")
phasorscale();

int No=0;
foreach(Graph *pg, Graphs) {
qDebug() << "load GraphData load" << defaultDataSet << pg->Var;
Expand Down Expand Up @@ -873,9 +747,6 @@ void Diagram::recalcGraphData()
yAxis.max = zAxis.max = xAxis.max = -DBL_MAX;
yAxis.numGraphs = zAxis.numGraphs = 0;

if(Name == "Phasor")
phasorscale();

// get maximum and minimum values
foreach(Graph *pg, Graphs)
getAxisLimits(pg);
Expand Down Expand Up @@ -1490,7 +1361,6 @@ bool Diagram::load(const QString& Line, QTextStream *stream)
xAxis.Label = s.section('"',1,1); // xLabel
yAxis.Label = s.section('"',3,3); // yLabel left
zAxis.Label = s.section('"',5,5); // yLabel right
sfreq = s.section('"',7,7); // frequency for phasor and waveac

Graph *pg;
// .......................................................
Expand Down Expand Up @@ -1818,7 +1688,7 @@ if(Axis->autoScale) {
Axis->low = Axis->min - fabs(Axis->min);
}
}
else if((Axis != &xAxis) || Name == "Phasor") {
else if((Axis != &xAxis)) {
// keep a small bounding between graph and diagram limit
Axis->up = Axis->max + 0.1*(Axis->max-Axis->min);
Axis->low = Axis->min - 0.1*(Axis->max-Axis->min);
Expand Down Expand Up @@ -2076,16 +1946,14 @@ else { // not logarithmical
if(fabs(GridNum) < 0.01*pow(10.0, Expo)) GridNum = 0.0;// make 0 really 0
tmp = misc::StringNiceNum(GridNum);

if(Name != "Phasor")
{
w = metrics.width(tmp); // width of text
w = metrics.width(tmp); // width of text
if(maxWidth < w) maxWidth = w;
if(x0 > 0)
Texts.append(new Text(x0+8, z-6, tmp)); // text aligned left
else
Texts.append(new Text(-w-7, z-6, tmp)); // text aligned right
GridNum += GridStep;
}


if(Axis->GridOn) if(z < y2) if(z > 0)
Lines.prepend(new Line(0, z, x2, z, GridPen)); // y grid
Expand Down Expand Up @@ -2113,8 +1981,10 @@ void Diagram::calcCoordinateP (const double*x, const double*y, const double*z, G
p->setScr(f1, f2);
};

/*only for phasor diagram detect if the points are in the diagram,
if not tell with are the limits that the point has passed*/

/* PHASOR AND WAVEAC RELATED CODE
//only for phasor diagram detect if the points are in the diagram,
// if not tell with are the limits that the point has passed
bool Diagram::insideDiagramPh(Graph::iterator const& p ,float* xn, float* yn) const
{
float f1 = p->getScrX();
Expand All @@ -2138,9 +2008,9 @@ bool Diagram::insideDiagramPh(Graph::iterator const& p ,float* xn, float* yn) co
return ((xa == f1)&&(ya == f2));
}
/*for phasor if the original point isn't in diagram with the limits calculated in insideDiagramPh
will create a point inside the diagram if possible */
bool Diagram::newcoordinate(Graph::iterator const& p,float* xn, float* yn) const //aqui
//for phasor if the original point isn't in diagram with the limits calculated in insideDiagramPh
// will create a point inside the diagram if possible
bool Diagram::newcoordinate(Graph::iterator const& p,float* xn, float* yn) const
{
float f1 = (p-1)->getScrX();
float f2 = (p-1)->getScrY();
Expand Down Expand Up @@ -2199,7 +2069,7 @@ bool Diagram::newcoordinate(Graph::iterator const& p,float* xn, float* yn) const
}
}
/*scales use in phasor and waveac this function only reset the value of the limits every scale*/
//scales use in phasor and waveac this function only reset the value of the limits every scale
void Diagram::phasorscale()
{
xAxisV.min = xAxisI.min = xAxisP.min = xAxisZ.min = DBL_MAX;
Expand All @@ -2209,7 +2079,7 @@ void Diagram::phasorscale()
zAxisV.min = zAxisI.min = zAxisP.min = zAxisZ.min = DBL_MAX;
zAxisV.max = zAxisI.max = zAxisP.max = zAxisZ.max = -DBL_MAX;
}
/*for phasor diagram while detect with type of graph it is (voltage, current....) and save in the auxiliary axis */
//for phasor diagram while detect with type of graph it is (voltage, current....) and save in the auxiliary axis
void Diagram::findaxisA(Graph *g)
{
QString var = g->Var;
Expand Down Expand Up @@ -2244,7 +2114,7 @@ void Diagram::findaxisA(Graph *g)
}
}
/*will determine the value of the graph for one frequency*/
//will determine the value of the graph for one frequency
bool Diagram::findmatch(Graph *g , int m)
{
double *px;
Expand All @@ -2270,8 +2140,8 @@ bool Diagram::findmatch(Graph *g , int m)
}
/*will read the values receive and find if is one the values determined by AC and remove repeated number.
if there isn't any value that match will find the closest number and replace*/
// will read the values receive and find if is one the values determined by AC and remove repeated number.
// if there isn't any value that match will find the closest number and replace
void Diagram::findfreq(Graph *g)
{
if(freq!=nullptr) delete[] freq;
Expand Down Expand Up @@ -2434,7 +2304,7 @@ void Diagram::findfreq(Graph *g)
}
/* for phasor will find the biggest absolute value of all max limits and replace the others*/
// for phasor will find the biggest absolute value of all max limits and replace the others
void Diagram::setlimitsphasor(Axis *x ,Axis *y)
{
double yrx,yrn,yix,yin;
Expand Down Expand Up @@ -2462,9 +2332,9 @@ void Diagram::setlimitsphasor(Axis *x ,Axis *y)
}
/*for marker of waveac to find the value of x */
//for marker of waveac to find the value of x
double Diagram::wavevalX(int i) const
{
return i*xAxis.up/(sc*50);
}
// vim:ts=8:sw=2:noet
*/
Loading

0 comments on commit 8d1a894

Please sign in to comment.