Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DC Bias Points Bug Fix (Hackish) (READY) #286

Merged
merged 1 commit into from
Jun 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions qucs/qucs/dialogs/sweepdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QLineEdit>
#include <QValidator>
#include <QPushButton>
#include <QDebug>

// SpinBoxes are used to show the calculated bias points at the given set of sweep points
mySpinBox::mySpinBox(int Min, int Max, int Step, double *Val, QWidget *Parent)
Expand All @@ -46,7 +47,9 @@ mySpinBox::mySpinBox(int Min, int Max, int Step, double *Val, QWidget *Parent)
using namespace std;
QString mySpinBox::textFromValue(int Val) const
{
cout<<"Values + Val"<<*(Values+Val)<<endl;
if (Values == NULL) return "";

qDebug() << "Values + Val" << *(Values+Val) << endl;
return QString::number(*(Values+Val));
}

Expand All @@ -62,6 +65,8 @@ QValidator::State mySpinBox::validate ( QString & text, int & pos ) const
SweepDialog::SweepDialog(Schematic *Doc_)
: QDialog(Doc_)
{
qDebug() << "SweepDialog::SweepDialog()";

Doc = Doc_;

pGraph = setBiasPoints();
Expand Down Expand Up @@ -91,7 +96,7 @@ SweepDialog::SweepDialog(Schematic *Doc_)

for(unsigned ii=0; (pD=pGraph->axis(ii)); ++ii) {
all->addWidget(new QLabel(pD->Var, this), i,0);
//cout<<"count: "<<pD->count-1<<", points: "<<*pD->Points<<endl;
//cout<<"count: "<<pD->count-1<<", points: "<<*pD->Points<<endl;
//works only for linear:
/*double Min = pD->Points[0];
double Max = pD->Points[pD->count-1];
Expand Down Expand Up @@ -126,6 +131,9 @@ SweepDialog::~SweepDialog()
void SweepDialog::slotNewValue(int)
{
DataX *pD = pGraph->axis(0);

qDebug() << "SweepDialog::slotNewValue:pD->count:" << pD->count;

int Factor = 1, Index = 0;
QList<mySpinBox *>::const_iterator it;
for(it = BoxList.constBegin(); it != BoxList.constEnd(); it++) {
Expand All @@ -135,8 +143,9 @@ void SweepDialog::slotNewValue(int)
Index *= 2; // because of complex values

QList<Node *>::iterator node_it;
QList<double *>::const_iterator value_it;
QList<double *>::const_iterator value_it = ValueList.begin();
for(node_it = NodeList.begin(); node_it != NodeList.end(); node_it++) {
qDebug() << "SweepDialog::slotNewValue:(*node_it)->Name:" << (*node_it)->Name;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be after line 150.

(*node_it)->Name = misc::num2str(*((*value_it)+Index));
(*node_it)->Name += ((*node_it)->x1 & 0x10)? "A" : "V";
value_it++;
Expand All @@ -151,14 +160,24 @@ Graph* SweepDialog::setBiasPoints()
// When this function is entered, a simulation was performed.
// Thus, the node names are still in "node->Name".

qDebug() << "SweepDialog::setBiasPoints()";

bool hasNoComp;
Graph *pg = new Graph("");
Diagram *Diag = new Diagram();
QFileInfo Info(Doc->DocName);
QString DataSet = Info.dirPath() + QDir::separator() + Doc->DataSet;

Node *pn;
Element *pe;

// Note 1:
// Invalidate it so that "Graph::loadDatFile()" does not check for the previously loaded time.
// This is a current hack as "Graph::loadDatFile()" does not support multi-node data loading
// from the simulation results without refreshing (changing) or invalidating the timestamp.

NodeList.clear();
ValueList.clear();

// create DC voltage for all nodes
for(pn = Doc->Nodes->first(); pn != 0; pn = Doc->Nodes->next()) {
if(pn->Name.isEmpty()) continue;
Expand Down Expand Up @@ -190,7 +209,8 @@ Graph* SweepDialog::setBiasPoints()
}

pg->Var = pn->Name + ".V";
if(pg->loadDatFile(DataSet)) {
pg->lastLoaded = QDateTime(); // Note 1 at the start of this function
if(pg->loadDatFile(DataSet) == 2) {
pn->Name = misc::num2str(*(pg->cPointsY)) + "V";
NodeList.append(pn); // remember node ...
ValueList.append(pg->cPointsY); // ... and all of its values
Expand Down Expand Up @@ -219,7 +239,8 @@ Graph* SweepDialog::setBiasPoints()

pn->x1 = 0x10; // mark current
pg->Var = pc->Name + ".I";
if(pg->loadDatFile(DataSet)) {
pg->lastLoaded = QDateTime(); // Note 1 at the start of this function
if(pg->loadDatFile(DataSet) == 2) {
pn->Name = misc::num2str(*(pg->cPointsY)) + "A";
NodeList.append(pn); // remember node ...
ValueList.append(pg->cPointsY); // ... and all of its values
Expand All @@ -239,6 +260,6 @@ Graph* SweepDialog::setBiasPoints()


Doc->showBias = 1;
delete Diag;

return pg;
}
5 changes: 1 addition & 4 deletions qucs/qucs/dialogs/sweepdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Graph;
class Schematic;
class QGridLayout;


class mySpinBox : public QSpinBox {
Q_OBJECT
public:
Expand All @@ -42,12 +41,10 @@ class mySpinBox : public QSpinBox {
QValidator::State validate ( QString & text, int & pos ) const;

private:
double *Values;
double *Values = NULL;
int ValueSize;
};



class SweepDialog : public QDialog {
Q_OBJECT
public:
Expand Down