Skip to content

Commit

Permalink
Fixes and improvements to the commited modules.
Browse files Browse the repository at this point in the history
The aspect ratio of the two new diagrams is now changeable.
Added some more clarity to the internal resistance parameter.
Deleted a lot of unused variables and functions.
Changed names of the diagrams and one variable to better follow convention.
Added components and diagrams to CMakelists.
Most of this was achieved under the guidance on Andrés Mera, I thank him for
all his help.
  • Loading branch information
gildias committed Jul 9, 2017
1 parent 7610343 commit 0edf230
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 46 deletions.
2 changes: 1 addition & 1 deletion qucs-core/src/acsolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int acsolver::solve (void) {
c->calcOperatingPoints ();
//if it detects any voltage, the ohmmeter will not work
if((c->getOperatingPoint ("R") != 0 ||
c->getOperatingPoint ("Z") != 0)) c->setstate(0);
c->getOperatingPoint ("X") != 0)) c->setstate(0);
}
/*if the circuit analysis has finished and the ohmmeterdidn't detect
any voltage, it will start the internal corrent source*/
Expand Down
2 changes: 2 additions & 0 deletions qucs-core/src/components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ SET( COMPONENTS_SRC
mutual.cpp
mutual2.cpp
mutualx.cpp
ohmmeter.cpp
opamp.cpp
open.cpp
pac.cpp
Expand Down Expand Up @@ -69,6 +70,7 @@ SET( COMPONENTS_SRC
vpulse.cpp
vrect.cpp
vvnoise.cpp
wprobe.cpp
)

SET(HEADERS
Expand Down
6 changes: 3 additions & 3 deletions qucs-core/src/components/ohmmeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ void ohmmeter::calcOperatingPoints (void) {
if(on>0)// Testing if the ohmmeter is already working or allowed to work
{
nr_double_t R = real (getV (NODE_1) - getV (NODE_2));
nr_double_t Z = imag (getV (NODE_1) - getV (NODE_2));
nr_double_t X = imag (getV (NODE_1) - getV (NODE_2));
setOperatingPoint ("R", R);
setOperatingPoint ("Z", Z);
setOperatingPoint ("X", X);
}
else // if it is connected to an external source, it will show as NAN
{
nr_double_t R=NAN;
setOperatingPoint ("R", R);
setOperatingPoint ("Z", R);
setOperatingPoint ("X", R);
}

}
Expand Down
4 changes: 2 additions & 2 deletions qucs-core/src/nasolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1379,11 +1379,11 @@ void nasolver<nr_type_t>::saveResults (const std::string &volts, const std::stri
continue;
}
//add ohmmeter data
if (strcmp(p.getName(), "Z") == 0) continue;
if (strcmp(p.getName(), "X") == 0) continue;
if (strcmp(p.getName(), "R") == 0) {//create values for ohmmeter
std::string n = createOP (c->getName (), "Ohm");
saveVariable (n, nr_complex_t (c->getOperatingPoint ("R"),
c->getOperatingPoint ("Z")), f);
c->getOperatingPoint ("X")), f);
continue;
}

Expand Down
3 changes: 2 additions & 1 deletion qucs/qucs/components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ componentdialog.cpp inductor.cpp noise_vv.cpp vcvs.cpp
iprobe.cpp opamp.cpp verilogfile.cpp vcresistor.cpp
coplanar.cpp ipulse.cpp opt_sim.cpp vexp.cpp
coupler.cpp irect.cpp optimizedialog.cpp vfile.cpp
cpwgap.cpp isolator.cpp vhdlfile.cpp
cpwgap.cpp isolator.cpp ohmmeter.cpp vhdlfile.cpp
cpwopen.cpp jfet.cpp pad2bit.cpp volt_ac.cpp
cpwshort.cpp jk_flipflop.cpp pad3bit.cpp volt_dc.cpp
cpwstep.cpp jkff_SR.cpp pad4bit.cpp volt_noise.cpp
Expand Down Expand Up @@ -171,6 +171,7 @@ nigbt.h
noise_ii.h
noise_iv.h
noise_vv.h
ohmmeter.h
opamp.h
opt_sim.h
optimizedialog.h
Expand Down
2 changes: 1 addition & 1 deletion qucs/qucs/components/ampere_ac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Ampere_ac::Ampere_ac()
Props.append(new Property("Theta", "0", false,
QObject::tr("damping factor (transient simulation only)")));
Props.append(new Property("Ri", "0 Ohm", false,
QObject::tr("Internal resistance, (0 : disable), ideal behavior")));
QObject::tr("Internal resistance, (0 : disable)")));

rotate(); // fix historical flaw
}
Expand Down
2 changes: 1 addition & 1 deletion qucs/qucs/components/ampere_dc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Ampere_dc::Ampere_dc()
Props.append(new Property("I", "1 mA", true,
QObject::tr("current in Ampere")));
Props.append(new Property("Ri", "0 Ohm", false,
QObject::tr("Internal resistance, (0 : disable), ideal behavior")));
QObject::tr("Internal resistance, (0 : disable)")));

rotate(); // fix historical flaw
}
Expand Down
2 changes: 1 addition & 1 deletion qucs/qucs/components/iprobe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ iProbe::iProbe()
Description = QObject::tr("current probe");

Props.append(new Property("Ri", "0 Ohm", false,
QObject::tr("Internal resistance, (0 : disable), ideal behavior")));
QObject::tr("Internal resistance, (0 : disable)")));

Lines.append(new Line(-30, 0,-20, 0,QPen(Qt::darkBlue,2)));
Lines.append(new Line( 30, 0, 20, 0,QPen(Qt::darkBlue,2)));
Expand Down
2 changes: 1 addition & 1 deletion qucs/qucs/components/volt_ac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Volt_ac::Volt_ac()
Props.append(new Property("Theta", "0", false,
QObject::tr("damping factor (transient simulation only)")));
Props.append(new Property("Ri", "0 Ohm", false,
QObject::tr("Internal resistance, (0 : disable), ideal behavior")));
QObject::tr("Internal resistance, (0 : disable)")));


rotate(); // fix historical flaw
Expand Down
2 changes: 1 addition & 1 deletion qucs/qucs/components/volt_dc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Volt_dc::Volt_dc()
Props.append(new Property("U", "1 V", true,
QObject::tr("voltage in Volts")));
Props.append(new Property("Ri", "0 Ohm", false,
QObject::tr("Internal resistance, (0 : disable), ideal behavior")));
QObject::tr("Internal resistance, (0 : disable)")));

rotate(); // fix historical flaw
}
Expand Down
3 changes: 2 additions & 1 deletion qucs/qucs/components/vprobe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
vProbe::vProbe()
{
Description = QObject::tr("voltage probe");

Props.append(new Property("Ri", "0 Ohm", false,
QObject::tr("Internal resistance, (0 : disable), ideal behavior")));
QObject::tr("Internal resistance, (0 : disable)")));

Lines.append(new Line(-20,-31, 20,-31,QPen(Qt::darkBlue,2)));
Lines.append(new Line(-20, 9, 20, 9,QPen(Qt::darkBlue,2)));
Expand Down
4 changes: 2 additions & 2 deletions qucs/qucs/components/wprobe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ wProbe::wProbe()
Description = QObject::tr("power probe");

Props.append(new Property("Riv", "0 Ohm", false,
QObject::tr("Internal resistance, (0 : disable), ideal behavior")));
QObject::tr("Voltage probe internal resistor, (0 : disable)")));
Props.append(new Property("Rii", "0 Ohm", false,
QObject::tr("Internal resistance, (0 : disable), ideal behavior")));
QObject::tr("Current probe internal resistor, (0 : disable)")));

//Large box
Lines.append(new Line(-20,-33, 20,-33,QPen(Qt::darkBlue,2)));
Expand Down
4 changes: 3 additions & 1 deletion qucs/qucs/diagrams/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ diagrams.h
graph.h
marker.h
markerdialog.h
phasor.h
polardiagram.h
psdiagram.h
rect3ddiagram.h
Expand All @@ -21,13 +22,14 @@ smithdiagram.h
tabdiagram.h
timingdiagram.h
truthdiagram.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 truthdiagram.cpp
rectdiagram.cpp phasor.cpp truthdiagram.cpp waveac.cpp
)

SET(DIAGRAMS_MOC_HDRS
Expand Down
13 changes: 6 additions & 7 deletions qucs/qucs/diagrams/diagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void Diagram::paintScheme(Schematic *p)
*/
void Diagram::createAxisLabels()
{
int x, y, z, w, wmax = 0;
int x, y, w, wmax = 0;
QString Str;
// get size of text using the screen-compatible metric
QFontMetrics metrics(QucsSettings.font, 0);
Expand Down Expand Up @@ -687,7 +687,7 @@ void Diagram::getAxisLimits(Graph *pg)
{
// FIXME: Graph should know the limits. but it doesn't yet.
// we should only copy here. better: just wrap, dont use {x,y,z}Axis
int z,i,m=0;
int z,i=0;
double x, y, *p;
QString var, find;
DataX const *pD = pg->axis(0);
Expand Down Expand Up @@ -2150,7 +2150,7 @@ bool Diagram::newcoordinate(Graph::iterator const& p,float* xn, float* yn) const
float d;
float b;

if(((f1 > f3 - 3) && (f1 < f3 + 3)) || (f2 > f4 - 3) && (f2 < f4 + 3))
if(((f1 > f3 - 3) && (f1 < f3 + 3)) || ((f2 > f4 - 3) && (f2 < f4 + 3)))
{
d = 0.0;
b = 0.0;
Expand Down Expand Up @@ -2211,7 +2211,6 @@ void Diagram::phasorscale()
void Diagram::findaxisA(Graph *g)
{
QString var = g->Var;
int n;

xAxisA = &xAxis;
yAxisA = &yAxis;
Expand Down Expand Up @@ -2248,8 +2247,8 @@ bool Diagram::findmatch(Graph *g , int m)
{
double *px;
double *pz = g->cPointsY + 2*m*g->axis(0)->count;
int i,z;
if(freq <= 0)
int z;
if(freq <= (double*) 0)
{
freq=0;
sfreq = "0 Hz";
Expand Down Expand Up @@ -2323,7 +2322,7 @@ void Diagram::findfreq(Graph *g)
a = value.indexOf("hz",0,Qt::CaseInsensitive);
}

double *px,f=0,xa;
double *px,f=0;
int i,z;
double d,dmin=DBL_MAX;
num = value.mid(0,a);
Expand Down
5 changes: 2 additions & 3 deletions qucs/qucs/diagrams/marker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void Marker::fix()
}
if(diag()->Name!="Waveac") return;

int nn,x,y,d,dmin = INT_MAX;
int nn,x,d,dmin = INT_MAX;
Axis const *pa;
if(pGraph->yAxisNo == 0) pa = &(diag()->yAxis);
else pa = &(diag()->zAxis);
Expand Down Expand Up @@ -230,7 +230,6 @@ void Marker::createText()
double *pp;
nVarPos = pGraph->numAxes();
DataX const *pD;
double n;
if(diag()->Name!="Waveac")
{
auto p = pGraph->findSample(VarPos);
Expand Down Expand Up @@ -648,7 +647,7 @@ bool Marker::getSelected(int x_, int y_)
/*will find the y value of a point in time for waveac*/
double Marker::wavevalY(double xn,std::vector<double>& VarPos)
{
double *px,n;
double n;
double af=0.0; //angles
double A = 0.0;
double yp[2];
Expand Down
17 changes: 4 additions & 13 deletions qucs/qucs/diagrams/phasordiagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,15 @@ int PhasorDiagram::calcDiagram()
Texts.clear();
Arcs.clear();

double GridStep, corr, zD, zDstep, GridNum;
double GridStep, zD, zDstep, GridNum;
// get size of text using the screen-compatible metric
QFontMetrics metrics(QucsSettings.font, 0);
y1 = QucsSettings.font.pointSize() + 6;

x1 = 10; // position of label text
x3 = x2 + 7;
QString tmp;
bool back = false;
int z, w, valid = 0;
int z, valid = 0;

// ===== give "step" the right sign (if user made it wrong) ==============
xAxis.step = fabs(xAxis.step);
Expand All @@ -127,9 +126,6 @@ int PhasorDiagram::calcDiagram()
// ==== x grid =======================================================

calcAxisScale(&xAxis, GridNum, zD, zDstep, GridStep, double(x2));
double Expo;
if(xAxis.up == 0.0) Expo = log10(fabs(xAxis.up-xAxis.low));
else Expo = log10(fabs(xAxis.up));

zD += 0.5; // perform rounding
z = int(zD); // "int(...)" implies "floor(...)"
Expand Down Expand Up @@ -160,7 +156,6 @@ int PhasorDiagram::calcDiagram()
calcRestAxis(&xAxisP,&yAxisP,&zAxisP);
calcRestAxis(&xAxisZ,&yAxisZ,&zAxisZ);

Frame:
// outer frame
Lines.append(new Line(0, y2, x2, y2, QPen(Qt::black,0)));
Lines.append(new Line(x2, y2, x2, 0, QPen(Qt::black,0)));
Expand Down Expand Up @@ -197,17 +192,13 @@ void PhasorDiagram::calcRestAxis(Axis *xA, Axis *yA , Axis *zA)

void PhasorDiagram::calcData(Graph *g)
{
double *px;
double *pz = g->cPointsY;
if(!pz) return;
if(g->numAxes() < 1) return;

int z,sc,i;
int z, i;
int Size = ((2*(g->count(0)) + 1)*nfreqt * g->countY) + 10;

double Dummy = 0.0; // not used
double *py;

g->resizeScrPoints(Size);
auto p = g->begin();
auto p_end = g->begin();
Expand Down Expand Up @@ -291,7 +282,7 @@ Diagram* PhasorDiagram::newOne()
// ------------------------------------------------------------
Element* PhasorDiagram::info(QString& Name, char* &BitmapFile, bool getNewOne)
{
Name = QObject::tr("Phasor(AC)");
Name = QObject::tr("AC Phasorial diagram");
BitmapFile = (char *) "phasor";

if(getNewOne) return new PhasorDiagram();
Expand Down
3 changes: 1 addition & 2 deletions qucs/qucs/diagrams/waveac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ else { // not logarithmical

void Waveac::calcData(Graph *g)
{
double *px;
double *pz = g->cPointsY;
if(!pz) return;
if(g->numAxes() < 1) return;
Expand Down Expand Up @@ -319,7 +318,7 @@ Diagram* Waveac::newOne()
// ------------------------------------------------------------
Element* Waveac::info(QString& Name, char* &BitmapFile, bool getNewOne)
{
Name = QObject::tr("Temporal Diagram(AC)");
Name = QObject::tr("AC Temporal diagram");
BitmapFile = (char *) "wave";

if(getNewOne) return new Waveac();
Expand Down
2 changes: 2 additions & 0 deletions qucs/qucs/mouseactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,8 @@ void MouseActions::MPressSelect(Schematic *Doc, QMouseEvent *Event, float fX, fl
if(((Diagram*)focusElement)->Name.left(4) != "Rect")
if(((Diagram*)focusElement)->Name.at(0) != 'T')
if(((Diagram*)focusElement)->Name != "Curve")
if(((Diagram*)focusElement)->Name != "Waveac")
if(((Diagram*)focusElement)->Name != "Phasor")
isMoveEqual = true; // diagram must be square

focusElement->Type = isDiagram;
Expand Down
7 changes: 2 additions & 5 deletions qucs/qucs/viewpainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void ViewPainter::init(QPainter *p, float Scale_, int DX_, int DY_,
p-> setMatrixEnabled(false); // we use our own coordinate transformation

QPainter::RenderHints hints = 0;
// Ask to to antialias drawings if requested
// Ask to antialias drawings if requested
if (QucsSettings.GraphAntiAliasing) hints |= QPainter::Antialiasing;
// Ask to antialias text if requested
if (QucsSettings.TextAntiAliasing) hints |= QPainter::TextAntialiasing;
Expand Down Expand Up @@ -206,8 +206,7 @@ void Graph::drawvect(int x0, int y0, ViewPainter *p) const
pp++;
continue;
}
if(pp->getScrX() != -1)//if true, draw the arrow head
{

phi = atan2(double(y2-y1), double(x2-x1));
beta = atan2(double(4), double(10));
double alfa = beta+phi;
Expand All @@ -223,8 +222,6 @@ void Graph::drawvect(int x0, int y0, ViewPainter *p) const

Painter->drawLine(QLineF(x4, y4, x2, y2));

}
else pp++;
}

}
Expand Down

0 comments on commit 0edf230

Please sign in to comment.