New Feature: CDL netlist export

Introduced very basic c++ coding style for the class Schematic and it's
parent-class QucsDoc based on https://google.github.io/styleguide/cppguide.html:
-Prefix class attributes with a_ (much more better readability!)
-Class member initialization via constructor member initialization list
-No public class attributes (where possible with small effort)

Signed-off-by: ThomasZecha <zecha@ihp-microelectronics.com>
This commit is contained in:
ThomasZecha 2024-11-08 12:46:57 +01:00
parent 9d55075db8
commit 62cf2d4bdc
34 changed files with 1698 additions and 1596 deletions

View File

@ -1465,7 +1465,7 @@ void Component::copyComponent(Component *pc) {
// ***********************************************************************
void MultiViewComponent::recreate(Schematic *Doc) {
if (Doc) {
Doc->Components->setAutoDelete(false);
Doc->a_Components->setAutoDelete(false);
Doc->deleteComp(this);
}
@ -1493,7 +1493,7 @@ void MultiViewComponent::recreate(Schematic *Doc) {
if (Doc) {
Doc->insertRawComponent(this);
Doc->Components->setAutoDelete(true);
Doc->a_Components->setAutoDelete(true);
}
}

View File

@ -198,7 +198,7 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d)
if(Comp->Model == ".SW") { // parameter sweep
Component *pc;
for(pc=Doc->Components->first(); pc!=0; pc=Doc->Components->next()) {
for(pc=Doc->a_Components->first(); pc!=0; pc=Doc->a_Components->next()) {
// insert all schematic available simulations in the Simulation combo box
if(pc != Comp)
if(pc->Model[0] == '.')
@ -1112,7 +1112,7 @@ void ComponentDialog::slotBrowseFile()
// -------------------------------------------------------------------------
void ComponentDialog::slotEditFile()
{
Doc->App->editFile(misc::properAbsFileName(edit->text(), Doc));
Doc->getApp()->editFile(misc::properAbsFileName(edit->text(), Doc));
}
/*!
@ -1490,8 +1490,8 @@ QStringList ComponentDialog::getSimulationList()
return sim_lst;
}
sim_lst.append("ALL");
for (size_t i = 0; i < sch->DocComps.count(); i++) {
Component *c = sch->DocComps.at(i);
for (size_t i = 0; i < sch->a_DocComps.count(); i++) {
Component *c = sch->a_DocComps.at(i);
if (!c->isSimulation) continue;
if (c->Model == ".FOUR") continue;
if (c->Model == ".PZ") continue;

View File

@ -347,7 +347,7 @@ OptimizeDialog::OptimizeDialog(Optimize_Sim *c_, Schematic *d_)
// ...........................................................
Component *pc;
for(pc=Doc->Components->first(); pc!=0; pc=Doc->Components->next())
for(pc=Doc->a_Components->first(); pc!=0; pc=Doc->a_Components->next())
if(pc != Comp)
if(pc->Model[0] == '.' && pc->Model != ".Opt")
SimEdit->insertItem(SimEdit->count(), pc->Name);
@ -728,7 +728,7 @@ void OptimizeDialog::slotApply()
NameEdit->setText(Comp->Name);
else
if(NameEdit->text() != Comp->Name) {
for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next())
for(pc = Doc->a_Components->first(); pc!=0; pc = Doc->a_Components->next())
if(pc->Name == NameEdit->text())
break; // found component with the same name ?
if(pc)

View File

@ -92,7 +92,7 @@ int SP_Sim::getSPortsNumber()
{
int p_num = 0;
if (containingSchematic != NULL) {
auto comps = containingSchematic->DocComps;
auto comps = containingSchematic->a_DocComps;
for(Component *pc = comps.first(); pc != 0; pc = comps.next()) {
if (pc->Model == "Pac") p_num++;
}

View File

@ -212,7 +212,7 @@ void SpiceDialog::slotButtApply()
if(CompNameEdit->text().isEmpty()) CompNameEdit->setText(Comp->Name);
else if(CompNameEdit->text() != Comp->Name)
{
for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next())
for(pc = Doc->a_Components->first(); pc!=0; pc = Doc->a_Components->next())
if(pc->Name == CompNameEdit->text()) {
break; // found component with the same name ?
}
@ -644,7 +644,7 @@ void SpiceDialog::slotGetNetlist()
// -------------------------------------------------------------------------
void SpiceDialog::slotButtEdit()
{
Doc->App->editFile(misc::properAbsFileName(FileEdit->text(), Doc));
Doc->getApp()->editFile(misc::properAbsFileName(FileEdit->text(), Doc));
}
// -------------------------------------------------------------------------

View File

@ -114,8 +114,8 @@ DiagramDialog::DiagramDialog(Diagram *d, QWidget *parent, Graph *currentGraph)
if(parent){
const Schematic* s = dynamic_cast<const Schematic*>(parent);
assert(s);
QFileInfo Info(s->DocName);
defaultDataSet = Info.absolutePath() + QDir::separator() + s->DataSet;
QFileInfo Info(s->getDocName());
defaultDataSet = Info.absolutePath() + QDir::separator() + s->getDataSet();
}else{
defaultDataSet = "unknown";
}

View File

@ -176,7 +176,7 @@ void ChangeDialog::slotButtReplace()
QString str;
int i1, i2;
// search through all components
for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next()) {
for(pc = Doc->a_Components->first(); pc!=0; pc = Doc->a_Components->next()) {
if(matches(pc->Model)) {
QRegularExpressionMatch match = Expr.match(pc->Name);
if(match.hasMatch())
@ -229,7 +229,7 @@ void ChangeDialog::slotButtReplace()
pb = i.next();
if(!pb->isChecked()) continue;
for(pc = Doc->Components->first(); pc!=0; pc = Doc->Components->next()) {
for(pc = Doc->a_Components->first(); pc!=0; pc = Doc->a_Components->next()) {
if(pb->text() != pc->Name) continue;
for(auto pp : pc->Props) {

View File

@ -104,7 +104,7 @@ DigiSettingsDialog::DigiSettingsDialog(TextDoc *Doc_)
all->addLayout(Buttons);
simRadio->setChecked(Doc->simulation);
Doc->SimOpenDpl = Doc->simulation ? true : false;
Doc->setSimOpenDpl(Doc->simulation ? true : false);
comRadio->setChecked(!Doc->simulation);
slotChangeMode(!Doc->simulation);
@ -135,7 +135,7 @@ void DigiSettingsDialog::slotOk()
reject();
return;
} else {
Doc->SimTime = s;
Doc->setSimTime(s);
changed = true;
}
}
@ -147,7 +147,7 @@ void DigiSettingsDialog::slotOk()
}
if(Doc->simulation != simRadio->isChecked()) {
Doc->simulation = simRadio->isChecked();
Doc->SimOpenDpl = Doc->simulation ? true : false;
Doc->setSimOpenDpl(Doc->simulation ? true : false);
changed = true;
}
if(Doc->Library != NameEdit->text()) {

View File

@ -448,12 +448,12 @@ void LibraryDialog::slotSave()
arg(SelectedNames[i]));
break;
}
Doc->DocName = NameEdit->text() + "_" + SelectedNames[i];
Doc->setDocName(NameEdit->text() + "_" + SelectedNames[i]);
Success = false;
// save analog model
tmp.truncate(0);
Doc->isAnalog = true;
Doc->setIsAnalog(true);
ErrText->insertPlainText("\n");
ErrText->insertPlainText(tr("Creating Qucs netlist.\n"));
@ -504,7 +504,7 @@ void LibraryDialog::slotSave()
if (!kern->checkSchematic(err_lst)) {
ErrText->insertPlainText(QStringLiteral("Component %1 contains SPICE-incompatible components.\n"
"Check these components: %2 \n")
.arg(Doc->DocName).arg(err_lst.join("; ")));
.arg(Doc->getDocName()).arg(err_lst.join("; ")));
}
kern->createSubNetlsit(ts,true);
intoStream(Stream, tmp, "Spice");
@ -514,8 +514,8 @@ void LibraryDialog::slotSave()
// save verilog model
tmp.truncate(0);
Doc->isVerilog = true;
Doc->isAnalog = false;
Doc->setIsVerilog(true);
Doc->setIsAnalog(false);
ErrText->insertPlainText("\n");
ErrText->insertPlainText(tr("Creating Verilog netlist.\n"));
@ -552,8 +552,8 @@ void LibraryDialog::slotSave()
// save vhdl model
tmp.truncate(0);
Doc->isVerilog = false;
Doc->isAnalog = false;
Doc->setIsVerilog(false);
Doc->setIsAnalog(false);
ErrText->insertPlainText(tr("Creating VHDL netlist.\n"));
ret = Doc->createLibNetlist(&ts, ErrText, 0);
@ -590,7 +590,7 @@ void LibraryDialog::slotSave()
Stream << " <Symbol>\n";
Doc->createSubcircuitSymbol();
Painting *pp;
for(pp = Doc->SymbolPaints.first(); pp != 0; pp = Doc->SymbolPaints.next())
for(pp = Doc->a_SymbolPaints.first(); pp != 0; pp = Doc->a_SymbolPaints.next())
Stream << " <" << pp->save() << ">\n";
Stream << " </Symbol>\n"

View File

@ -92,7 +92,7 @@ void SaveDialog::initDialog()
void SaveDialog::addUnsavedDoc(QucsDoc *doc)
{
QString text = (doc->DocName).isEmpty() ? tr("Untitled") : doc->DocName;
QString text = (doc->getDocName()).isEmpty() ? tr("Untitled") : doc->getDocName();
QListWidgetItem *item = new QListWidgetItem(text, fileView);
item->setFlags( item->flags() | Qt::ItemIsUserCheckable );

View File

@ -165,24 +165,24 @@ SettingsDialog::SettingsDialog(Schematic *Doc_)
// ...........................................................
// fill the fields with the QucsDoc-Properties
Input_DataSet->setText(Doc->DataSet);
Input_DataDisplay->setText(Doc->DataDisplay);
Input_Script->setText(Doc->Script);
Check_OpenDpl->setChecked(Doc->SimOpenDpl);
Check_RunScript->setChecked(Doc->SimRunScript);
Check_GridOn->setChecked(Doc->GridOn);
Input_GridX->setText(QString::number(Doc->GridX));
Input_GridY->setText(QString::number(Doc->GridY));
Combo_Frame->setCurrentIndex(Doc->showFrame);
Input_DataSet->setText(Doc->getDataSet());
Input_DataDisplay->setText(Doc->getDataDisplay());
Input_Script->setText(Doc->getScript());
Check_OpenDpl->setChecked(Doc->getSimOpenDpl());
Check_RunScript->setChecked(Doc->getSimRunScript());
Check_GridOn->setChecked(Doc->getGridOn());
Input_GridX->setText(QString::number(Doc->getGridX()));
Input_GridY->setText(QString::number(Doc->getGridY()));
Combo_Frame->setCurrentIndex(Doc->getShowFrame());
QString Text_;
decode_String(Text_ = Doc->Frame_Text0);
decode_String(Text_ = Doc->getFrame_Text0());
Input_Frame0->setText(Text_);
decode_String(Text_ = Doc->Frame_Text1);
decode_String(Text_ = Doc->getFrame_Text1());
Input_Frame1->setText(Text_);
decode_String(Text_ = Doc->Frame_Text2);
decode_String(Text_ = Doc->getFrame_Text2());
Input_Frame2->setText(Text_);
decode_String(Text_ = Doc->Frame_Text3);
decode_String(Text_ = Doc->getFrame_Text3());
Input_Frame3->setText(Text_);
resize(250, 200);
@ -229,86 +229,86 @@ void SettingsDialog::slotApply()
{
bool changed = false;
if(Doc->DataSet != Input_DataSet->text())
if(Doc->getDataSet() != Input_DataSet->text())
{
Doc->DataSet = Input_DataSet->text();
Doc->setDataSet(Input_DataSet->text());
changed = true;
}
if(Doc->DataDisplay != Input_DataDisplay->text())
if(Doc->getDataDisplay() != Input_DataDisplay->text())
{
Doc->DataDisplay = Input_DataDisplay->text();
Doc->setDataDisplay(Input_DataDisplay->text());
changed = true;
}
if(Doc->Script != Input_Script->text())
if(Doc->getScript() != Input_Script->text())
{
Doc->Script = Input_Script->text();
Doc->setScript(Input_Script->text());
changed = true;
}
if(Doc->SimOpenDpl != Check_OpenDpl->isChecked())
if(Doc->getSimOpenDpl() != Check_OpenDpl->isChecked())
{
Doc->SimOpenDpl = Check_OpenDpl->isChecked();
Doc->setSimOpenDpl(Check_OpenDpl->isChecked());
changed = true;
}
if(Doc->SimRunScript != Check_RunScript->isChecked())
if(Doc->getSimRunScript() != Check_RunScript->isChecked())
{
Doc->SimRunScript = Check_RunScript->isChecked();
Doc->setSimRunScript(Check_RunScript->isChecked());
changed = true;
}
if(Doc->GridOn != Check_GridOn->isChecked())
if(Doc->getGridOn() != Check_GridOn->isChecked())
{
Doc->GridOn = Check_GridOn->isChecked();
Doc->setGridOn(Check_GridOn->isChecked());
changed = true;
}
if(Doc->GridX != Input_GridX->text().toInt())
if(Doc->getGridX() != Input_GridX->text().toInt())
{
Doc->GridX = Input_GridX->text().toInt();
Doc->setGridX(Input_GridX->text().toInt());
changed = true;
}
if(Doc->GridY != Input_GridY->text().toInt())
if(Doc->getGridY() != Input_GridY->text().toInt())
{
Doc->GridY = Input_GridY->text().toInt();
Doc->setGridY(Input_GridY->text().toInt());
changed = true;
}
if(Doc->showFrame != Combo_Frame->currentIndex())
if(Doc->getShowFrame() != Combo_Frame->currentIndex())
{
Doc->showFrame = Combo_Frame->currentIndex();
Doc->setShowFrame(Combo_Frame->currentIndex());
changed = true;
}
QString t;
encode_String(Input_Frame0->toPlainText(), t);
if(Doc->Frame_Text0 != t)
if(Doc->getFrame_Text0() != t)
{
Doc->Frame_Text0 = t;
Doc->setFrame_Text0(t);
changed = true;
}
encode_String(Input_Frame1->text(), t);
if(Doc->Frame_Text1 != t)
if(Doc->getFrame_Text1() != t)
{
Doc->Frame_Text1 = t;
Doc->setFrame_Text1(t);
changed = true;
}
encode_String(Input_Frame2->text(), t);
if(Doc->Frame_Text2 != t)
if(Doc->getFrame_Text2() != t)
{
Doc->Frame_Text2 = t;
Doc->setFrame_Text2(t);
changed = true;
}
encode_String(Input_Frame3->text(), t);
if(Doc->Frame_Text3 != t)
if(Doc->getFrame_Text3() != t)
{
Doc->Frame_Text3 = t;
Doc->setFrame_Text3(t);
changed = true;
}

View File

@ -72,15 +72,15 @@ SimMessage::SimMessage(QWidget *w, QWidget *parent)
else
Doc = (QucsDoc*) ((Schematic*)DocWidget);
DocName = Doc->DocName;
DataDisplay = Doc->DataDisplay;
Script = Doc->Script;
DocName = Doc->getDocName();
DataDisplay = Doc->getDataDisplay();
Script = Doc->getScript();
QFileInfo Info(DocName);
DataSet = QDir::toNativeSeparators(Info.path()) +
QDir::separator() + Doc->DataSet;
showBias = Doc->showBias; // save some settings as the document...
SimOpenDpl = Doc->SimOpenDpl; // ...could be closed during the simulation.
SimRunScript = Doc->SimRunScript;
QDir::separator() + Doc->getDataSet();
showBias = Doc->getShowBias(); // save some settings as the document...
SimOpenDpl = Doc->getSimOpenDpl(); // ...could be closed during the simulation.
SimRunScript = Doc->getSimRunScript();
all = new QVBoxLayout(this);
all->setSpacing(5);
@ -379,7 +379,7 @@ void SimMessage::startSimulator()
// Simulation.
if (Doc->simulation) {
SimTime = Doc->SimTime;
SimTime = Doc->getSimTime();
QString libs = Doc->Libraries.toLower();
/// \todo \bug error: unrecognized command line option '-Wl'
#if defined(_WIN32) || defined(__MINGW32__)
@ -449,8 +449,7 @@ void SimMessage::startSimulator()
// Simulate schematic window.
else {
// output NodeSets, SPICE simulations etc.
for(QStringList::Iterator it = Collect.begin();
it != Collect.end(); ++it) {
for(QStringList::Iterator it = Collect.begin(); it != Collect.end(); ++it) {
// don't put library includes into netlist...
if ((*it).right(4) != ".lst" &&
(*it).right(5) != ".vhdl" &&
@ -461,7 +460,7 @@ void SimMessage::startSimulator()
}
Stream << '\n';
isVerilog = ((Schematic*)DocWidget)->isVerilog;
isVerilog = ((Schematic*)DocWidget)->getIsVerilog();
SimTime = ((Schematic*)DocWidget)->createNetlist(Stream, SimPorts);
if(SimTime.length()>0&&SimTime.at(0) == '\xA7') {
NetlistFile.close();
@ -646,7 +645,7 @@ void SimMessage::startSimulator()
// ------------------------------------------------------------------------
Component * SimMessage::findOptimization(Schematic *Doc) {
Component *pc;
for(pc=Doc->Components->first(); pc!=0; pc=Doc->Components->next())
for(pc=Doc->a_Components->first(); pc!=0; pc=Doc->a_Components->next())
if(pc->isActive)
if(pc->Model == ".Opt")
return pc;
@ -903,15 +902,14 @@ void SimMessage::setDocWidget(QWidget *w)
else
Doc = (QucsDoc*) ((Schematic*)DocWidget);
DocName = Doc->DocName;
DataDisplay = Doc->DataDisplay;
Script = Doc->Script;
DocName = Doc->getDocName();
DataDisplay = Doc->getDataDisplay();
Script = Doc->getScript();
QFileInfo Info(DocName);
DataSet = QDir::toNativeSeparators(Info.path()) +
QDir::separator() + Doc->DataSet;
showBias = Doc->showBias; // save some settings as the document...
SimOpenDpl = Doc->SimOpenDpl; // ...could be closed during the simulation.
SimRunScript = Doc->SimRunScript;
QDir::separator() + Doc->getDataSet();
showBias = Doc->getShowBias(); // save some settings as the document...
SimOpenDpl = Doc->getSimOpenDpl(); // ...could be closed during the simulation.
SimRunScript = Doc->getSimRunScript();
}
// vim:ts=8:sw=2:et

View File

@ -169,8 +169,8 @@ Graph* SweepDialog::setBiasPoints(QHash<QString,double> *NodeVals)
bool hasNoComp;
Graph *pg = new Graph(NULL, ""); // HACK!
QFileInfo Info(Doc->DocName);
QString DataSet = Info.absolutePath() + QDir::separator() + Doc->DataSet;
QFileInfo Info(Doc->getDocName());
QString DataSet = Info.absolutePath() + QDir::separator() + Doc->getDataSet();
Node *pn;
@ -183,7 +183,7 @@ Graph* SweepDialog::setBiasPoints(QHash<QString,double> *NodeVals)
ValueList.clear();
// create DC voltage for all nodes
for(pn = Doc->Nodes->first(); pn != 0; pn = Doc->Nodes->next()) {
for(pn = Doc->a_Nodes->first(); pn != 0; pn = Doc->a_Nodes->next()) {
if(pn->Name.isEmpty()) continue;
pn->x1 = 0;
@ -242,7 +242,7 @@ Graph* SweepDialog::setBiasPoints(QHash<QString,double> *NodeVals)
// create DC current through each probe
Component *pc;
for(pc = Doc->Components->first(); pc != 0; pc = Doc->Components->next())
for(pc = Doc->a_Components->first(); pc != 0; pc = Doc->a_Components->next())
if(pc->Model == "IProbe") {
pn = pc->Ports.first()->Connection;
if(!pn->Name.isEmpty()) // preserve node voltage ?
@ -298,7 +298,7 @@ Graph* SweepDialog::setBiasPoints(QHash<QString,double> *NodeVals)
}
Doc->showBias = 1;
Doc->setShowBias(1);
return pg;
}

View File

@ -178,8 +178,8 @@ void VASettingsDialog::slotOk ()
Doc->LongDesc = LongDescEdit->text ();
changed = true;
}
if (Doc->DataSet != OutputEdit->text ()) {
Doc->DataSet = OutputEdit->text ();
if (Doc->getDataSet() != OutputEdit->text ()) {
Doc->setDataSet(OutputEdit->text ());
changed = true;
}
if (Doc->recreate != RecreateCheck->isChecked ()) {

View File

@ -56,7 +56,7 @@ AbstractSpiceKernel::AbstractSpiceKernel(Schematic *schematic, QObject *parent)
a_sims(),
a_vars(),
a_output_files(),
a_DC_OP_only(schematic->showBias == 0 ? true : false),
a_DC_OP_only(schematic->getShowBias() == 0 ? true : false),
a_needsPrefix(false),
a_schematic(schematic),
a_parseFourTHD(false),
@ -64,7 +64,7 @@ AbstractSpiceKernel::AbstractSpiceKernel(Schematic *schematic, QObject *parent)
{
if (!checkDCSimulation()) { // Run Show bias mode automatically
a_DC_OP_only = true; // If schematic contains DC simulation only
a_schematic->showBias = 0;
a_schematic->setShowBias(0);
}
a_workdir = QucsSettings.S4Qworkdir;
@ -128,7 +128,7 @@ bool AbstractSpiceKernel::prepareSpiceNetlist(QTextStream &stream, bool isSubckt
bool AbstractSpiceKernel::checkSchematic(QStringList &incompat)
{
incompat.clear();
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if ((!pc->isEquation)&&!(pc->isProbe)) {
if (pc->SpiceModel.isEmpty() && pc->isActive) incompat.append(pc->Name);
}
@ -144,7 +144,7 @@ bool AbstractSpiceKernel::checkSchematic(QStringList &incompat)
bool AbstractSpiceKernel::checkGround()
{
bool r = false;
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if (pc->Model=="GND") {
r = true;
break;
@ -157,7 +157,7 @@ bool AbstractSpiceKernel::checkSimulations()
{
if (a_DC_OP_only) return true;
bool r = false;
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if (pc->isSimulation) {
r = true;
break;
@ -172,7 +172,7 @@ bool AbstractSpiceKernel::checkDCSimulation()
//if (a_DC_OP_only) return true;
//bool r = false;
//for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
//for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
// if (!pc->isActive) continue;
// if (pc->isSimulation && pc->Model != ".DC") {
// r = true;
@ -196,7 +196,7 @@ void AbstractSpiceKernel::startNetlist(QTextStream &stream, bool xyce)
QString s;
// User-defined functions
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if ((pc->SpiceModel==".FUNC")||
(pc->SpiceModel=="INCLSCR")) {
s = pc->getExpression();
@ -206,7 +206,7 @@ void AbstractSpiceKernel::startNetlist(QTextStream &stream, bool xyce)
// create .IC from wire labels
QStringList wire_labels;
for(Wire *pw = a_schematic->DocWires.first(); pw != 0; pw = a_schematic->DocWires.next()) {
for(Wire *pw = a_schematic->a_DocWires.first(); pw != 0; pw = a_schematic->a_DocWires.next()) {
if (pw->Label != nullptr) {
QString label = pw->Label->Name;
if (!wire_labels.contains(label)) wire_labels.append(label);
@ -218,7 +218,7 @@ void AbstractSpiceKernel::startNetlist(QTextStream &stream, bool xyce)
}
}
}
for(Node *pn = a_schematic->DocNodes.first(); pn != 0; pn = a_schematic->DocNodes.next()) {
for(Node *pn = a_schematic->a_DocNodes.first(); pn != 0; pn = a_schematic->a_DocNodes.next()) {
Conductor *pw = (Conductor*) pn;
if (pw->Label != nullptr) {
QString label = pw->Label->Name;
@ -233,7 +233,7 @@ void AbstractSpiceKernel::startNetlist(QTextStream &stream, bool xyce)
}
// Parameters, Initial conditions, Options
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if (pc->isEquation) {
s = pc->getExpression(xyce);
stream<<s;
@ -241,8 +241,8 @@ void AbstractSpiceKernel::startNetlist(QTextStream &stream, bool xyce)
}
// Components
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
if(a_schematic->isAnalog &&
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if(a_schematic->getIsAnalog() &&
!(pc->isSimulation) &&
!(pc->isEquation)) {
s = pc->getSpiceNetlist(xyce);
@ -251,7 +251,7 @@ void AbstractSpiceKernel::startNetlist(QTextStream &stream, bool xyce)
}
// Modelcards
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if (pc->SpiceModel==".MODEL") {
s = pc->getSpiceModel();
stream<<s;
@ -279,7 +279,7 @@ void AbstractSpiceKernel::createNetlist(QTextStream&, int ,QStringList&,
void AbstractSpiceKernel::createSubNetlsit(QTextStream &stream, bool lib)
{
QString header;
QString f = misc::properFileName(a_schematic->DocName);
QString f = misc::properFileName(a_schematic->getDocName());
header = QStringLiteral(".SUBCKT %1 ").arg(misc::properName(f));
QList< QPair<int,QString> > ports;
@ -288,7 +288,7 @@ void AbstractSpiceKernel::createSubNetlsit(QTextStream &stream, bool lib)
emit errors(QProcess::FailedToStart);
return;
} // Unable to perform spice simulation
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if (pc->Model=="Port") {
ports.append(qMakePair(pc->Props.first()->Value.toInt(),
pc->Ports.first()->Connection->Name));
@ -301,7 +301,7 @@ void AbstractSpiceKernel::createSubNetlsit(QTextStream &stream, bool lib)
}
Painting *pai;
for(pai = a_schematic->SymbolPaints.first(); pai != 0; pai = a_schematic->SymbolPaints.next())
for(pai = a_schematic->a_SymbolPaints.first(); pai != 0; pai = a_schematic->a_SymbolPaints.next())
if(pai->Name == ".ID ") {
ID_Text *pid = (ID_Text*)pai;
QList<SubParameter *>::const_iterator it;
@ -701,7 +701,7 @@ void AbstractSpiceKernel::parseDC_OPoutput(QString ngspice_file)
SweepDialog *swpdlg = new SweepDialog(a_schematic,&NodeVals);
delete swpdlg;
a_schematic->showBias = 1;
a_schematic->setShowBias(1);
}
/*!
@ -735,7 +735,7 @@ void AbstractSpiceKernel::parseDC_OPoutputXY(QString xyce_file)
SweepDialog *swpdlg = new SweepDialog(a_schematic,&NodeVals);
delete swpdlg;
a_schematic->showBias = 1;
a_schematic->setShowBias(1);
}
/*!
@ -1528,7 +1528,7 @@ bool AbstractSpiceKernel::waitEndOfSimulation()
QString AbstractSpiceKernel::collectSpiceLibs(Schematic* sch)
{
QStringList collected_spicelib;
for(Component *pc = sch->DocComps.first(); pc != 0; pc = sch->DocComps.next()) {
for(Component *pc = sch->a_DocComps.first(); pc != 0; pc = sch->a_DocComps.next()) {
if (pc->Model == "Sub") {
Schematic *sub = new Schematic(0, ((Subcircuit *)pc)->getSubcircuitFile());
if(!sub->loadDocument()) // load document if possible

View File

@ -163,14 +163,14 @@ void CustomSimDialog::slotCancel()
void CustomSimDialog::slotFindVars()
{
QStringList vars;
for(Node *pn = a_schematic->DocNodes.first(); pn != 0; pn = a_schematic->DocNodes.next()) {
for(Node *pn = a_schematic->a_DocNodes.first(); pn != 0; pn = a_schematic->a_DocNodes.next()) {
if(pn->Label != 0) {
if (!vars.contains(pn->Label->Name)) {
vars.append(pn->Label->Name);
}
}
}
for(Wire *pw = a_schematic->DocWires.first(); pw != 0; pw = a_schematic->DocWires.next()) {
for(Wire *pw = a_schematic->a_DocWires.first(); pw != 0; pw = a_schematic->a_DocWires.next()) {
if(pw->Label != 0) {
if (!vars.contains(pw->Label->Name)) {
vars.append(pw->Label->Name);
@ -178,7 +178,7 @@ void CustomSimDialog::slotFindVars()
}
}
for(Component *pc=a_schematic->DocComps.first();pc!=0;pc=a_schematic->DocComps.next()) {
for(Component *pc=a_schematic->a_DocComps.first();pc!=0;pc=a_schematic->a_DocComps.next()) {
if(pc->isProbe) {
if (!vars.contains(pc->getProbeVariable())) {
vars.append(pc->getProbeVariable());

View File

@ -90,7 +90,7 @@ ExternSimDialog::ExternSimDialog(Schematic *sch, bool netlist_mode) :
setLayout(vl_top);
slotSetSimulator();
if (!netlist_mode && !QucsMain->TuningMode && a_schematic->showBias != 0)
if (!netlist_mode && !QucsMain->TuningMode && a_schematic->getShowBias() != 0)
slotStart(); // Start simulation
}
@ -211,7 +211,7 @@ void ExternSimDialog::slotProcessOutput()
a_editSimConsole->insertPlainText("Simulation finished\n");
if ( !a_hasError ) {
QFileInfo inf(a_schematic->DocName);
QFileInfo inf(a_schematic->getDocName());
//QString qucs_dataset = inf.canonicalPath()+QDir::separator()+inf.baseName()+"_ngspice.dat";
QString qucs_dataset = inf.canonicalPath()+QDir::separator()+inf.completeBaseName()+ext;
switch (QucsSettings.DefaultSimulator) {
@ -230,7 +230,7 @@ void ExternSimDialog::slotProcessOutput()
//if (out.contains("error",Qt::CaseInsensitive))
// a_hasError = true;
emit simulated(this);
//if (a_schematic->showBias>0 || QucsMain->TuningMode) this->close();
//if (a_schematic->getShowBias()>0 || QucsMain->TuningMode) this->close();
}
@ -294,7 +294,7 @@ void ExternSimDialog::slotStop()
void ExternSimDialog::slotSaveNetlist()
{
QFileInfo inf(a_schematic->DocName);
QFileInfo inf(a_schematic->getDocName());
QString filename = QFileDialog::getSaveFileName(this,tr("Save netlist"),inf.path()+QDir::separator()+"netlist.cir",
"All files (*)");
if (filename.isEmpty()) return;

View File

@ -72,7 +72,7 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
{
Q_UNUSED(simulations);
stream << "* Qucs " << PACKAGE_VERSION << " " << a_schematic->DocName << "\n";
stream << "* Qucs " << PACKAGE_VERSION << " " << a_schematic->getDocName() << "\n";
// include math. functions for inter-simulator compat.
QString mathf_inc;
@ -101,14 +101,14 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
// set variable names for named nodes and wires
vars.clear();
for(Node *pn = a_schematic->DocNodes.first(); pn != 0; pn = a_schematic->DocNodes.next()) {
for(Node *pn = a_schematic->a_DocNodes.first(); pn != 0; pn = a_schematic->a_DocNodes.next()) {
if(pn->Label != 0) {
if (!vars.contains(pn->Label->Name)) {
vars.append(pn->Label->Name);
}
}
}
for(Wire *pw = a_schematic->DocWires.first(); pw != 0; pw = a_schematic->DocWires.next()) {
for(Wire *pw = a_schematic->a_DocWires.first(); pw != 0; pw = a_schematic->a_DocWires.next()) {
if(pw->Label != 0) {
if (!vars.contains(pw->Label->Name)) {
vars.append(pw->Label->Name);
@ -116,7 +116,7 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
}
}
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if (pc->isProbe) {
QString var_pr = pc->getProbeVariable();
if (!vars.contains(var_pr)) {
@ -150,8 +150,8 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
unsigned int pzSims = 0;
outputs.clear();
for ( unsigned int i = 0 ; i < a_schematic->DocComps.count() ; i++ ) {
Component *pc = a_schematic->DocComps.at(i);
for ( unsigned int i = 0 ; i < a_schematic->a_DocComps.count() ; i++ ) {
Component *pc = a_schematic->a_DocComps.at(i);
if ( !pc->isSimulation ) continue;
if ( pc->isActive != COMP_IS_ACTIVE ) continue;
@ -164,8 +164,8 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
QString cnt_var;
// Duplicate .PARAM in .control section. They may be used in euqations
for ( unsigned int i = 0 ; i < a_schematic->DocComps.count() ; i++ ) {
Component *pc1 = a_schematic->DocComps.at(i);
for ( unsigned int i = 0 ; i < a_schematic->a_DocComps.count() ; i++ ) {
Component *pc1 = a_schematic->a_DocComps.at(i);
if ( pc1->isActive != COMP_IS_ACTIVE ) continue;
if ( pc1->Model == "Eqn" ) {
spiceNetlist.append((reinterpret_cast<Equation *>(pc1))->getNgspiceScript());
@ -180,8 +180,8 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
nods.append(QStringLiteral("v(%1) ").arg(nod));
}
for ( unsigned int i = 0 ; i < a_schematic->DocComps.count() ; i++ ) {
Component *pc1 = a_schematic->DocComps.at(i);
for ( unsigned int i = 0 ; i < a_schematic->a_DocComps.count() ; i++ ) {
Component *pc1 = a_schematic->a_DocComps.at(i);
if ( !pc1->isSimulation ) continue;
if ( pc1->isActive != COMP_IS_ACTIVE ) continue;
QString sim_typ = pc1->Model;
@ -204,8 +204,8 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
} else if ( sim_typ == ".TR" ) {
timeSims++;
spiceNetlist.append(pc->getSpiceNetlist());
for ( unsigned int i = 0 ; i < a_schematic->DocComps.count() ; i++ ) {
Component *pc1 = a_schematic->DocComps.at(i);
for ( unsigned int i = 0 ; i < a_schematic->a_DocComps.count() ; i++ ) {
Component *pc1 = a_schematic->a_DocComps.at(i);
if ( !pc1->isSimulation ) continue;
if ( pc1->isActive != COMP_IS_ACTIVE ) continue;
if ( pc1->Model == ".FOURIER" ) {
@ -308,8 +308,8 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
if ( (sim_typ != ".PZ") && (sim_typ != ".SENS") && (sim_typ != ".SENS_AC") ) {
QStringList dep_vars;
for ( unsigned int i = 0 ; i < a_schematic->DocComps.count() ; i++ ) {
Component *pc1 = a_schematic->DocComps.at(i);
for ( unsigned int i = 0 ; i < a_schematic->a_DocComps.count() ; i++ ) {
Component *pc1 = a_schematic->a_DocComps.at(i);
if ( pc1->isActive != COMP_IS_ACTIVE ) continue;
if ( pc1->Model == "Eqn" || pc1->Model == "NutmegEq" )
spiceNetlist.append(pc1->getEquations(sim_name, dep_vars));
@ -338,8 +338,8 @@ void Ngspice::createNetlist(QTextStream &stream, int ,
}
}
for ( unsigned int i = 0 ; i < a_schematic->DocComps.count() ; i++ ) {
Component *pc1 = a_schematic->DocComps.at(i);
for ( unsigned int i = 0 ; i < a_schematic->a_DocComps.count() ; i++ ) {
Component *pc1 = a_schematic->a_DocComps.at(i);
if ( !pc1->isSimulation ) continue;
if ( pc1->isActive != COMP_IS_ACTIVE ) continue;
QString sim_typ = pc1->Model;
@ -386,8 +386,8 @@ QString Ngspice::getParentSWPscript(Component *pc_swp, QString sim, bool before,
{
hasDblSwp = false;
QString swp = pc_swp->Name.toLower();
for ( unsigned int i = 0 ; i < a_schematic->DocComps.count() ; i++ ) {
Component *pc = a_schematic->DocComps.at(i);
for ( unsigned int i = 0 ; i < a_schematic->a_DocComps.count() ; i++ ) {
Component *pc = a_schematic->a_DocComps.at(i);
if ( !pc->isSimulation ) continue;
if ( pc->isActive != COMP_IS_ACTIVE ) continue;
if ( pc->Model == ".SW" ) {
@ -500,7 +500,7 @@ void Ngspice::slotSimulate()
bool Ngspice::checkNodeNames(QStringList &incompat)
{
bool result = true;
for(Node *pn = a_schematic->DocNodes.first(); pn != 0; pn = a_schematic->DocNodes.next()) {
for(Node *pn = a_schematic->a_DocNodes.first(); pn != 0; pn = a_schematic->a_DocNodes.next()) {
if(pn->Label != 0) {
if (!spicecompat::check_nodename(pn->Label->Name)) {
incompat.append(pn->Label->Name);
@ -508,7 +508,7 @@ bool Ngspice::checkNodeNames(QStringList &incompat)
}
}
}
for(Wire *pw = a_schematic->DocWires.first(); pw != 0; pw = a_schematic->DocWires.next()) {
for(Wire *pw = a_schematic->a_DocWires.first(); pw != 0; pw = a_schematic->a_DocWires.next()) {
if(pw->Label != 0) {
if (!spicecompat::check_nodename(pw->Label->Name)) {
incompat.append(pw->Label->Name);
@ -527,7 +527,7 @@ bool Ngspice::checkNodeNames(QStringList &incompat)
QString Ngspice::collectSpiceinit(Schematic* sch)
{
QStringList collected_spiceinit;
for(Component *pc = sch->DocComps.first(); pc != 0; pc = sch->DocComps.next()) {
for(Component *pc = sch->a_DocComps.first(); pc != 0; pc = sch->a_DocComps.next()) {
if (pc->Model == "SPICEINIT") {
collected_spiceinit += ((SpiceSpiceinit*)pc)->getSpiceinit();
} else if (pc->Model == "Sub") {

View File

@ -159,7 +159,7 @@ bool VerilogAwriter::createVA_module(QTextStream &stream, Schematic *sch)
ports.clear();
nodes.clear();
for(Component *pc = sch->DocComps.first(); pc != 0; pc = sch->DocComps.next()) {
for(Component *pc = sch->a_DocComps.first(); pc != 0; pc = sch->a_DocComps.next()) {
if (pc->Model=="Port") { // Find module ports
QString s = pc->Ports.first()->Connection->Name;
if (!ports.contains(s)) ports.append(s);
@ -174,7 +174,7 @@ bool VerilogAwriter::createVA_module(QTextStream &stream, Schematic *sch)
if (ports.isEmpty()) return false; // Not a subcircuit
QFileInfo inf(sch->DocName);
QFileInfo inf(sch->getDocName());
QString base = inf.completeBaseName();
base.remove('-').remove(' ');
nodes.removeAll("gnd"); // Exclude ground node
@ -184,7 +184,7 @@ bool VerilogAwriter::createVA_module(QTextStream &stream, Schematic *sch)
stream<<QStringLiteral("electrical %1;\n").arg(nodes.join(", "));
Painting *pi; // Find module parameters
for(pi = sch->SymbolPaints.first(); pi != 0; pi = sch->SymbolPaints.next())
for(pi = sch->a_SymbolPaints.first(); pi != 0; pi = sch->a_SymbolPaints.next())
if(pi->Name == ".ID ") {
ID_Text *pid = (ID_Text*)pi;
QList<SubParameter *>::const_iterator it;
@ -197,7 +197,7 @@ bool VerilogAwriter::createVA_module(QTextStream &stream, Schematic *sch)
// List all variables
for(Component *pc = sch->DocComps.first(); pc != 0; pc = sch->DocComps.next()) {
for(Component *pc = sch->a_DocComps.first(); pc != 0; pc = sch->a_DocComps.next()) {
if (pc->isEquation && pc->isActive) {
stream<<pc->getVAvariables();
}
@ -207,7 +207,7 @@ bool VerilogAwriter::createVA_module(QTextStream &stream, Schematic *sch)
"@(initial_model)\n"
"begin \n";
// Output expressions
for(Component *pc = sch->DocComps.first(); pc != 0; pc = sch->DocComps.next()) {
for(Component *pc = sch->a_DocComps.first(); pc != 0; pc = sch->a_DocComps.next()) {
if (pc->isEquation && pc->isActive) {
stream<<pc->getVAExpressions();
}
@ -216,7 +216,7 @@ bool VerilogAwriter::createVA_module(QTextStream &stream, Schematic *sch)
stream<<"end\n";
// Convert components to current equations.
for(Component *pc = sch->DocComps.first(); pc != 0; pc = sch->DocComps.next()) {
for(Component *pc = sch->a_DocComps.first(); pc != 0; pc = sch->a_DocComps.next()) {
stream<<pc->getVerilogACode();
}

View File

@ -51,7 +51,7 @@ Xyce::Xyce(Schematic *schematic, QObject *parent) :
void Xyce::determineUsedSimulations(QStringList *sim_lst)
{
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if(pc->isSimulation && pc->isActive == COMP_IS_ACTIVE) {
QString sim_typ = pc->Model;
if (sim_typ==".AC") a_simulationsQueue.append("ac");
@ -85,7 +85,7 @@ void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
QString s;
bool hasParSweep = false;
stream << "* Qucs " << PACKAGE_VERSION << " " << a_schematic->DocName << "\n";
stream << "* Qucs " << PACKAGE_VERSION << " " << a_schematic->getDocName() << "\n";
stream<<collectSpiceLibs(a_schematic); // collect libraries on the top of netlist
if(!prepareSpiceNetlist(stream)) return; // Unable to perform spice simulation
@ -94,21 +94,21 @@ void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
// set variable names for named nodes and wires
vars.clear();
for(Node *pn = a_schematic->DocNodes.first(); pn != 0; pn = a_schematic->DocNodes.next()) {
for(Node *pn = a_schematic->a_DocNodes.first(); pn != 0; pn = a_schematic->a_DocNodes.next()) {
if(pn->Label != 0) {
if (!vars.contains(pn->Label->Name)) {
vars.append(pn->Label->Name);
}
}
}
for(Wire *pw = a_schematic->DocWires.first(); pw != 0; pw = a_schematic->DocWires.next()) {
for(Wire *pw = a_schematic->a_DocWires.first(); pw != 0; pw = a_schematic->a_DocWires.next()) {
if(pw->Label != 0) {
if (!vars.contains(pw->Label->Name)) {
vars.append(pw->Label->Name);
}
}
}
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if (pc->isProbe) {
QString var_pr = pc->getProbeVariable(true);
if (!vars.contains(var_pr)) {
@ -125,13 +125,13 @@ void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
if (a_DC_OP_only) {
// Add all remaining nodes, because XYCE has no equivalent for PRINT ALL
for(Node* pn = a_schematic->Nodes->first(); pn != 0; pn = a_schematic->Nodes->next()) {
for(Node* pn = a_schematic->a_Nodes->first(); pn != 0; pn = a_schematic->a_Nodes->next()) {
if ((!vars.contains(pn->Name))&&(pn->Name!="gnd")) {
vars.append(pn->Name);
}
}
// Add DC sources
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if ((pc->Model == "S4Q_V")||(pc->Model == "Vdc")) {
vars.append("I("+pc->Name+")");
}
@ -142,7 +142,7 @@ void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
//execute simulations
//QFileInfo inf(a_schematic->DocName);
//QFileInfo inf(a_schematic->getDocName());
//QString basenam = inf.baseName();
QString basenam = "spice4qucs";
@ -165,7 +165,7 @@ void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
QString sim = simulations.first();
QStringList spar_vars;
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) { // Xyce can run
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) { // Xyce can run
if(pc->isSimulation && pc->isActive == COMP_IS_ACTIVE) { // only one simulations per time.
QString sim_typ = pc->Model; // Multiple simulations are forbidden.
QString s = pc->getSpiceNetlist(true);
@ -180,7 +180,7 @@ void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
if (sim==pc->Name) stream<<s; // Xyce scripts
if ((sim_typ==".TR")&&(sim=="tran")){
stream<<s;
Q3PtrList<Component> comps(a_schematic->DocComps); // find Fourier tran
Q3PtrList<Component> comps(a_schematic->a_DocComps); // find Fourier tran
for(Component *pc1 = comps.first(); pc1 != 0; pc1 = comps.next()) {
if (pc1->Model==".FOURIER") {
if (pc1->Props.at(0)->Value==pc->Name) {
@ -214,7 +214,7 @@ void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
stream<<s;
hasParSweep = true;
} else if (SwpSim.startsWith("SW")&&(sim=="dc")) {
for(Component *pc1 = a_schematic->DocComps.first(); pc1 != 0; pc1 = a_schematic->DocComps.next()) {
for(Component *pc1 = a_schematic->a_DocComps.first(); pc1 != 0; pc1 = a_schematic->a_DocComps.next()) {
if ((pc1->Name==SwpSim)&&(pc1->Props.at(0)->Value.startsWith("DC"))) {
stream<<s;
hasParSweep = true;
@ -227,7 +227,7 @@ void Xyce::createNetlist(QTextStream &stream, int , QStringList &simulations,
}
if (sim.startsWith("XYCESCR")) {
for(Component *pc = a_schematic->DocComps.first(); pc != 0; pc = a_schematic->DocComps.next()) {
for(Component *pc = a_schematic->a_DocComps.first(); pc != 0; pc = a_schematic->a_DocComps.next()) {
if (pc->isSimulation)
if (sim == pc->Name)
outputs.append(pc->Props.at(2)->Value.split(';'));

View File

@ -446,11 +446,11 @@ int doPrint(QString schematic, QString printFile,
return 1;
}
sch->Nodes = &(sch->DocNodes);
sch->Wires = &(sch->DocWires);
sch->Diagrams = &(sch->DocDiags);
sch->Paintings = &(sch->DocPaints);
sch->Components = &(sch->DocComps);
sch->a_Nodes = &(sch->a_DocNodes);
sch->a_Wires = &(sch->a_DocWires);
sch->a_Diagrams = &(sch->a_DocDiags);
sch->a_Paintings = &(sch->a_DocPaints);
sch->a_Components = &(sch->a_DocComps);
sch->reloadGraphs();
qDebug() << "*** try to print file :" << printFile;

View File

@ -90,8 +90,8 @@ void MouseActions::setPainter(Schematic *Doc)
// contents to viewport transformation
Doc->PostPaintEvent(_Translate, -Doc->contentsX(), -Doc->contentsY());
Doc->PostPaintEvent(_Scale, Doc->Scale, Doc->Scale);
Doc->PostPaintEvent(_Translate, -Doc->ViewX1, -Doc->ViewY1);
Doc->PostPaintEvent(_Scale, Doc->getScale(), Doc->getScale());
Doc->PostPaintEvent(_Translate, -Doc->getViewX1(), -Doc->getViewY1());
Doc->PostPaintEvent(_NotRop);
}
@ -208,10 +208,10 @@ void MouseActions::endElementMoving(Schematic *Doc,
Doc->insertWire((Wire *)pe);
break;
case isDiagram:
Doc->Diagrams->append((Diagram *)pe);
Doc->a_Diagrams->append((Diagram *)pe);
break;
case isPainting:
Doc->Paintings->append((Painting *)pe);
Doc->a_Paintings->append((Painting *)pe);
break;
case isComponent:
case isAnalogComponent:
@ -628,7 +628,7 @@ void MouseActions::MMoveScrollBar(Schematic *Doc, QMouseEvent *Event)
// FIXME #warning QPainter p(Doc->viewport());
// FIXME #warning ViewPainter Painter;
// FIXME #warning Painter.init(&p, Doc->Scale, -Doc->ViewX1, -Doc->ViewY1,
// FIXME #warning Painter.init(&p, Doc->a_Scale, -Doc->getViewX1(), -Doc->getViewY1(),
// FIXME #warning Doc->contentsX(), Doc->contentsY());
// FIXME #warning Painter.fillRect(d->cx-d->x1, d->cy-d->y2, d->x2+d->x1, d->y2+d->y1,
// FIXME #warning QucsSettings.BGColor);
@ -1326,7 +1326,7 @@ void MouseActions::MPressRotate(Schematic *Doc, QMouseEvent *, float fX, float f
case isWire:
pl = ((Wire *) e)->Label;
((Wire *) e)->Label = 0; // prevent label to be deleted
Doc->Wires->setAutoDelete(false);
Doc->a_Wires->setAutoDelete(false);
Doc->deleteWire((Wire *) e);
((Wire *) e)->Label = pl;
((Wire *) e)->rotate();
@ -1335,8 +1335,8 @@ void MouseActions::MPressRotate(Schematic *Doc, QMouseEvent *, float fX, float f
if (pl)
Doc->setOnGrid(pl->cx, pl->cy);
Doc->insertWire((Wire *) e);
Doc->Wires->setAutoDelete(true);
if (Doc->Wires->containsRef((Wire *) e))
Doc->a_Wires->setAutoDelete(true);
if (Doc->a_Wires->containsRef((Wire *) e))
Doc->enlargeView(e->x1, e->y1, e->x2, e->y2);
break;
@ -1432,7 +1432,7 @@ void MouseActions::MPressElement(Schematic *Doc, QMouseEvent *Event, float, floa
return;
Diagram *Diag = (Diagram *) selElem;
QFileInfo Info(Doc->DocName);
QFileInfo Info(Doc->getDocName());
// dialog is Qt::WDestructiveClose !!!
DiagramDialog *dia = new DiagramDialog(Diag, Doc);
if (dia->exec() == QDialog::Rejected) { // don't insert if dialog canceled
@ -1440,7 +1440,7 @@ void MouseActions::MPressElement(Schematic *Doc, QMouseEvent *Event, float, floa
return;
}
Doc->Diagrams->append(Diag);
Doc->a_Diagrams->append(Diag);
Doc->enlargeView(Diag->cx, Diag->cy - Diag->y2, Diag->cx + Diag->x2, Diag->cy);
Doc->setChanged(true, true); // document has been changed
@ -1453,7 +1453,7 @@ void MouseActions::MPressElement(Schematic *Doc, QMouseEvent *Event, float, floa
// *********** it is a painting !!!
if (((Painting *) selElem)->MousePressing(Doc)) {
Doc->Paintings->append((Painting *) selElem);
Doc->a_Paintings->append((Painting *) selElem);
((Painting *) selElem)->Bounding(x1, y1, x2, y2);
//Doc->enlargeView(x1, y1, x2, y2);
selElem = ((Painting *) selElem)->newOne();
@ -1620,7 +1620,7 @@ void MouseActions::MPressSetLimits(Schematic *Doc, QMouseEvent*, float fX, float
// TODO: Diagrams is currently a Q3PtrList, but it would be better to refactor
// this (and many other collections) to be std::vector.
// Check to see if the mouse is within a diagram using the oddly named "getSelected".
for (Diagram* diagram = Doc->Diagrams->last(); diagram != 0; diagram = Doc->Diagrams->prev()) {
for (Diagram* diagram = Doc->a_Diagrams->last(); diagram != 0; diagram = Doc->a_Diagrams->prev()) {
// BUG: Obtaining the diagram type by name is marked as a bug elsewhere (to be solved separately).
// TODO: Currently only rectangular diagrams are supported.
if (diagram->getSelected(fX, fY) && diagram->Name == "Rect") {
@ -1746,7 +1746,7 @@ void MouseActions::MReleaseSelect2(Schematic *Doc, QMouseEvent *Event)
QucsMain->MouseReleaseAction = &MouseActions::MReleaseSelect;
QucsMain->MouseDoubleClickAction = &MouseActions::MDoubleClickSelect;
Doc->highlightWireLabels();
Doc->PostedPaintEvents.clear();
Doc->clearPostedPaintEvents();
Doc->viewport()->update();
}
@ -1869,7 +1869,7 @@ void MouseActions::MReleaseSetLimits(Schematic *Doc, QMouseEvent *Event)
qDebug() << "Mouse released after setting limits.";
// Check to see if the mouse is within a diagram using the oddly named "getSelected".
for (Diagram* diagram = Doc->Diagrams->last(); diagram != 0; diagram = Doc->Diagrams->prev()) {
for (Diagram* diagram = Doc->a_Diagrams->last(); diagram != 0; diagram = Doc->a_Diagrams->prev()) {
// Only process the selection if it ends in a diagram, and is the same diagram as start.
if (diagram->getSelected(MAx2, MAy2) && diagram == pActiveDiagram) {
@ -1887,8 +1887,8 @@ void MouseActions::MReleaseSetLimits(Schematic *Doc, QMouseEvent *Event)
diagram->setLimitsBySelectionRect(select);
// TODO: Consider refactoring loadGraphData to reload the current dataset if an empty string is passed.
QFileInfo Info(Doc->DocName);
QString defaultDataSet = Info.absolutePath() + QDir::separator() + Doc->DataSet;
QFileInfo Info(Doc->getDocName());
QString defaultDataSet = Info.absolutePath() + QDir::separator() + Doc->getDataSet();
diagram->loadGraphData(defaultDataSet);
Doc->setChanged(true, true);
@ -1968,7 +1968,7 @@ void MouseActions::rotateElements(Schematic *Doc, int &x1, int &y1)
void MouseActions::MReleasePaste(Schematic *Doc, QMouseEvent *Event)
{
int x1, y1, x2, y2, rot;
QFileInfo Info(Doc->DocName);
QFileInfo Info(Doc->getDocName());
//QPainter painter(Doc->viewport());
Element *pe;
@ -1983,19 +1983,19 @@ void MouseActions::MReleasePaste(Schematic *Doc, QMouseEvent *Event)
if (pe->y1 == pe->y2)
break;
Doc->insertWire((Wire *) pe);
if (Doc->Wires->containsRef((Wire *) pe))
if (Doc->a_Wires->containsRef((Wire *) pe))
Doc->enlargeView(pe->x1, pe->y1, pe->x2, pe->y2);
else
pe = NULL;
break;
case isDiagram:
Doc->Diagrams->append((Diagram *) pe);
Doc->a_Diagrams->append((Diagram *) pe);
((Diagram *) pe)
->loadGraphData(Info.absolutePath() + QDir::separator() + Doc->DataSet);
->loadGraphData(Info.absolutePath() + QDir::separator() + Doc->getDataSet());
Doc->enlargeView(pe->cx, pe->cy - pe->y2, pe->cx + pe->x2, pe->cy);
break;
case isPainting:
Doc->Paintings->append((Painting *) pe);
Doc->a_Paintings->append((Painting *) pe);
((Painting *) pe)->Bounding(x1, y1, x2, y2);
Doc->enlargeView(x1, y1, x2, y2);
break;
@ -2104,7 +2104,7 @@ void MouseActions::editElement(Schematic *Doc, QMouseEvent *Event)
MarkerDialog *mdia;
int x1, y1, x2, y2;
QFileInfo Info(Doc->DocName);
QFileInfo Info(Doc->getDocName());
auto inModel = Doc->contentsToModel(Event->pos());
float fX = static_cast<float>(inModel.x());
float fY = static_cast<float>(inModel.y());
@ -2144,10 +2144,10 @@ void MouseActions::editElement(Schematic *Doc, QMouseEvent *Event)
if (cd->exec() != 1)
break; // dialog is WDestructiveClose
Doc->Components->findRef(c);
Doc->Components->take();
Doc->a_Components->findRef(c);
Doc->a_Components->take();
Doc->setComponentNumber(c); // for ports/power sources
Doc->Components->append(c);
Doc->a_Components->append(c);
}
Doc->setChanged(true, true);
@ -2185,7 +2185,7 @@ void MouseActions::editElement(Schematic *Doc, QMouseEvent *Event)
case isGraph:
pg = (Graph *) focusElement;
// searching diagram for this graph
for (dia = Doc->Diagrams->last(); dia != 0; dia = Doc->Diagrams->prev())
for (dia = Doc->a_Diagrams->last(); dia != 0; dia = Doc->a_Diagrams->prev())
if (dia->Graphs.indexOf(pg) >= 0)
break;
if (!dia)
@ -2308,7 +2308,7 @@ void MouseActions::MPressTune(Schematic *Doc, QMouseEvent *Event, float fX, floa
if (!App->tunerDia->containsProperty(pp)) {
if (isPropertyTunable(pc, pp)) {
tunerElement *tune = new tunerElement(App->tunerDia, pc, pp, No);
tune->schematicName = Doc->DocName;
tune->schematicName = Doc->getDocName();
if (tune != NULL)
App->tunerDia->addTunerElement(tune); //Tunable property
} else {

View File

@ -235,7 +235,7 @@ void PortSymbol::mirrorY()
}
bool PortSymbol::MousePressing(Schematic *sch) {
if (!sch->isSymbolOnly) {
if (!sch->getIsSymbolOnly()) {
return false;
}
QString text = QInputDialog::getText(nullptr, QObject::tr("Port name"),
@ -266,7 +266,7 @@ bool PortSymbol::Dialog(QWidget* /*parent*/Doc) {
// Forbid manual editing, change port name on schematic to change it in the symbol
// Allow to edit ports only for SymbolOnly documents (*.sym).
Schematic *sch = (Schematic *) Doc;
if (!sch->isSymbolOnly) {
if (!sch->getIsSymbolOnly()) {
return false;
}

View File

@ -722,7 +722,7 @@ QucsDoc * QucsApp::findDoc (QString File, int * Pos)
int No = 0;
File = QDir::toNativeSeparators (File);
while ((d = getDoc (No++)) != 0)
if (QDir::toNativeSeparators (d->DocName) == File) {
if (QDir::toNativeSeparators (d->getDocName()) == File) {
if (Pos) *Pos = No - 1;
return d;
}
@ -1240,7 +1240,7 @@ void QucsApp::slotCMenuCopy()
//check changed file save
int z = 0; //search if the doc is loaded
QucsDoc *d = findDoc(file, &z);
if (d != NULL && d->DocChanged) {
if (d != NULL && d->getDocChanged()) {
DocumentTab->setCurrentIndex(z);
int ret = QMessageBox::question(this, tr("Copying Qucs document"),
tr("The document contains unsaved changes!\n") +
@ -1630,7 +1630,7 @@ void QucsApp::slotSymbolNew()
int i = addDocumentTab(d);
DocumentTab->setCurrentIndex(i);
slotSymbolEdit();
d->isSymbolOnly = true;
d->setIsSymbolOnly(true);
statusBar()->showMessage(tr("Ready."));
}
@ -1696,15 +1696,15 @@ bool QucsApp::gotoPage(const QString& Name)
// and skip any actions performed with a usual schematic.
Schematic *sch = (Schematic *)d;
slotSymbolEdit();
sch->isSymbolOnly = true;
sch->setIsSymbolOnly(true);
} else if (is_sch) {
Schematic *sch = (Schematic *)d;
if (sch->checkDplAndDatNames()) sch->setChanged(true,true);
}
// if only an untitled document was open -> close it
if(getDoc(0)->DocName.isEmpty())
if(!getDoc(0)->DocChanged)
if(getDoc(0)->getDocName().isEmpty())
if(!getDoc(0)->getDocChanged())
delete DocumentTab->widget(0);
return true;
@ -1740,7 +1740,7 @@ bool QucsApp::saveFile(QucsDoc *Doc)
if(!Doc)
Doc = getDoc();
if(Doc->DocName.isEmpty())
if(Doc->getDocName().isEmpty())
return saveAs();
int Result = Doc->save();
@ -1750,7 +1750,7 @@ bool QucsApp::saveFile(QucsDoc *Doc)
// definition. We don't want these files to be subject
// of any activities or "optimizations" which may change
// the symbol.
if (!Doc->DocName.endsWith(".sym")) {
if (!Doc->getDocName().endsWith(".sym")) {
updatePortNumber(Doc, Result);
}
slotUpdateTreeview();
@ -1788,7 +1788,7 @@ bool QucsApp::saveAs()
QString s, Filter;
QFileInfo Info;
while(true) {
s = Doc->DocName;
s = Doc->getDocName();
Info.setFile(s);
if(s.isEmpty()) { // which is default directory ?
if(ProjName.isEmpty()) {
@ -1813,7 +1813,7 @@ bool QucsApp::saveAs()
tr("Any File")+" (*)";
} else {
Schematic *sch = (Schematic *) Doc;
if (sch->isSymbolOnly) {
if (sch->getIsSymbolOnly()) {
Filter = tr("Subcircuit symbol") + "(*.sym)";
} else {
Filter = QucsFileFilter;
@ -1867,7 +1867,7 @@ bool QucsApp::saveAs()
// definition. We don't want these files to be subject
// of any activities or "optimizations" which may change
// the symbol.
if (!Doc->DocName.endsWith(".sym")) {
if (!Doc->getDocName().endsWith(".sym")) {
updatePortNumber(Doc, n);
}
@ -1911,7 +1911,7 @@ void QucsApp::slotFileSaveAll()
int No=0;
QucsDoc *Doc; // search, if page is already loaded
while((Doc=getDoc(No++)) != 0) {
if(Doc->DocName.isEmpty()) // make document the current ?
if(Doc->getDocName().isEmpty()) // make document the current ?
DocumentTab->setCurrentIndex(No-1);
if (saveFile(Doc)) { // Hack! TODO: Maybe it's better to let slotFileChanged()
setDocumentTabChanged(No-1, false); // know about Tab number?
@ -1962,7 +1962,7 @@ void QucsApp::closeFile(int index)
slotHideEdit(); // disable text edit of component property
QucsDoc *Doc = getDoc(index);
if(Doc->DocChanged) {
if(Doc->getDocChanged()) {
switch(QMessageBox::warning(this,tr("Closing Qucs document"),
tr("The document contains unsaved changes!\n")+
tr("Do you want to save the changes before closing?"),
@ -1994,7 +1994,7 @@ bool QucsApp::closeAllFiles()
sd->setApp(this);
for(int i=0; i < DocumentTab->count(); ++i) {
QucsDoc *doc = getDoc(i);
if(doc->DocChanged)
if(doc->getDocChanged())
sd->addUnsavedDoc(doc);
}
int Result = SaveDialog::DontSave;
@ -2079,7 +2079,7 @@ void QucsApp::slotChangeView()
// already in schematic?
if(cursorLeft->isEnabled()) {
// which mode: schematic or symbol editor ?
if((CompChoose->count() > 1) == d->symbolMode)
if((CompChoose->count() > 1) == d->getSymbolMode())
changeSchematicSymbolMode (d);
}
else {
@ -2091,7 +2091,7 @@ void QucsApp::slotChangeView()
Doc->becomeCurrent(true);
// TODO proper window title
// QFileInfo Info (Doc-> DocName);
// QFileInfo Info (Doc-> getDocName());
//
// if (!ProjName.isEmpty()) {
// QDir parentDir = QucsSettings.QucsWorkDir;
@ -2159,7 +2159,7 @@ void QucsApp::updatePortNumber(QucsDoc *currDoc, int No)
{
if(No<0) return;
QString pathName = currDoc->DocName;
QString pathName = currDoc->getDocName();
QString ext = currDoc->fileSuffix ();
QFileInfo Info (pathName);
QString Model, File, Name = Info.fileName();
@ -2183,19 +2183,19 @@ void QucsApp::updatePortNumber(QucsDoc *currDoc, int No)
// start from the last to omit re-appended components
Schematic *Doc = (Schematic*)w;
for(Component *pc=Doc->Components->last(); pc!=0; ) {
for(Component *pc=Doc->a_Components->last(); pc!=0; ) {
if(pc->Model == Model) {
File = pc->Props.front()->Value;
if((File == pathName) || (File == Name)) {
pc_tmp = Doc->Components->prev();
pc_tmp = Doc->a_Components->prev();
Doc->recreateComponent(pc); // delete and re-append component
if(!pc_tmp) break;
Doc->Components->findRef(pc_tmp);
pc = Doc->Components->current();
Doc->a_Components->findRef(pc_tmp);
pc = Doc->a_Components->current();
continue;
}
}
pc = Doc->Components->prev();
pc = Doc->a_Components->prev();
}
}
}
@ -2307,7 +2307,7 @@ void QucsApp::slotIntoHierarchy()
QString s = pc->getSubcircuitFile();
if(!gotoPage(s)) { return; }
HierarchyHistory.push(Doc->DocName); //remember for the way back
HierarchyHistory.push(Doc->getDocName()); //remember for the way back
popH->setEnabled(true);
}
@ -2386,7 +2386,7 @@ void QucsApp::slotTune(bool checked)
bool found = false;
bool digi_found = false;
bool exit = false;
for(Component *pc = d->DocComps.first(); pc != 0; pc = d->DocComps.next()) {
for(Component *pc = d->a_DocComps.first(); pc != 0; pc = d->a_DocComps.next()) {
if (pc->isSimulation) {
found = true;
}
@ -2404,7 +2404,7 @@ void QucsApp::slotTune(bool checked)
QMessageBox::warning(this,tr("Error"),tr("Tuning not possible for digital simulation. "
"Only analog simulation supported."));
}
if (d->Diagrams->isEmpty() && !d->SimOpenDpl) {
if (d->a_Diagrams->isEmpty() && !d->getSimOpenDpl()) {
QMessageBox::warning(this,tr("Error"),tr("Tuning has no effect without diagrams. "
"Add at least one diagram on schematic."));
exit = true;
@ -2448,10 +2448,10 @@ void QucsApp::slotTune(bool checked)
QWidget *QucsApp::getSchematicWidget(QucsDoc *Doc)
{
QWidget *w = nullptr;
QFileInfo Info(QucsSettings.QucsWorkDir.filePath(Doc->DataDisplay));
QFileInfo Info(QucsSettings.QucsWorkDir.filePath(Doc->getDataDisplay()));
int z = 0;
QFileInfo sch_inf(Doc->DocName);
QString sch_name = sch_inf.absolutePath() + QDir::separator() + Doc->DataDisplay;
QFileInfo sch_inf(Doc->getDocName());
QString sch_name = sch_inf.absolutePath() + QDir::separator() + Doc->getDataDisplay();
QucsDoc *d = findDoc(sch_name, &z); // check if schematic is already open in a Tab
if (d)
@ -2505,7 +2505,7 @@ void QucsApp::slotSimulate(QWidget *w)
Schematic* schematicPtr = (Schematic*)w;
isDigital = schematicPtr->isDigitalCircuit();
if (isDigital && schematicPtr->showBias == 0) {
if (isDigital && schematicPtr->getShowBias() == 0) {
QMessageBox::warning(this,tr("Simulate schematic"),
tr("DC bias simulation mode is not supported "
"for digital schematic!"));
@ -2524,7 +2524,7 @@ void QucsApp::slotSimulate(QWidget *w)
if(isTextDocument (w)) {
Doc = (QucsDoc*)((TextDoc*)w);
if(Doc->SimTime.isEmpty() && ((TextDoc*)Doc)->simulation) {
if(Doc->getSimTime().isEmpty() && ((TextDoc*)Doc)->simulation) {
DigiSettingsDialog *d = new DigiSettingsDialog((TextDoc*)Doc);
if(d->exec() == QDialog::Rejected)
return;
@ -2533,14 +2533,14 @@ void QucsApp::slotSimulate(QWidget *w)
else
Doc = (QucsDoc*)((Schematic*)w);
if(Doc->DocName.isEmpty()) // if document 'untitled' ...
if(Doc->getDocName().isEmpty()) // if document 'untitled' ...
if(!saveAs()) return; // ... save schematic before
// Perhaps the document was modified from another program ?
QFileInfo Info(Doc->DocName);
QFileInfo Info(Doc->getDocName());
QString ext = Info.suffix();
if(Doc->lastSaved.isValid()) {
if(Doc->lastSaved < Info.lastModified()) {
if(Doc->getLastSaved().isValid()) {
if(Doc->getLastSaved() < Info.lastModified()) {
int No = QMessageBox::warning(this, tr("Warning"),
tr("The document was modified by another program !") + '\n' +
tr("Do you want to reload or keep this version ?"),
@ -2554,10 +2554,10 @@ void QucsApp::slotSimulate(QWidget *w)
if(Info.suffix() == "m" || Info.suffix() == "oct") {
// It is an Octave script.
if(Doc->DocChanged)
if(Doc->getDocChanged())
Doc->save();
slotViewOctaveDock(true);
octave->runOctaveScript(Doc->DocName);
octave->runOctaveScript(Doc->getDocName());
return;
}
@ -2667,13 +2667,13 @@ void QucsApp::slotAfterSimulation(int Status, SimMessage *sim)
// ------------------------------------------------------------------------
void QucsApp::slotDCbias()
{
getDoc()->showBias = 0;
getDoc()->setShowBias(0);
slotSimulate();
}
// ------------------------------------------------------------------------
// Changes to the corresponding data display page or vice versa.
void QucsApp::slotChangePage(QString& DocName, QString& DataDisplay)
void QucsApp::slotChangePage(const QString& DocName, const QString& DataDisplay)
{
if(DataDisplay.isEmpty()) return;
@ -2712,7 +2712,7 @@ void QucsApp::slotChangePage(QString& DocName, QString& DataDisplay)
}
else {
if(file.open(QIODevice::ReadWrite)) { // if document doesn't exist, create
d->DataDisplay = Info.fileName();
d->setDataDisplay(Info.fileName());
slotUpdateTreeview();
}
else {
@ -2743,16 +2743,16 @@ void QucsApp::slotChangePage(QString& DocName, QString& DataDisplay)
void QucsApp::slotToPage()
{
QucsDoc *d = getDoc();
if(d->DataDisplay.isEmpty()) {
if(d->getDataDisplay().isEmpty()) {
QMessageBox::critical(this, tr("Error"), tr("No page set !"));
return;
}
if(d->DocName.right(2) == ".m" ||
d->DocName.right(4) == ".oct")
if(d->getDocName().right(2) == ".m" ||
d->getDocName().right(4) == ".oct")
slotViewOctaveDock(true);
else
slotChangePage(d->DocName, d->DataDisplay);
slotChangePage(d->getDocName(), d->getDataDisplay());
}
// -------------------------------------------------------------------
@ -3054,7 +3054,7 @@ void QucsApp::switchEditMode(bool SchematicMode)
// ---------------------------------------------------------
void QucsApp::changeSchematicSymbolMode(Schematic *Doc)
{
if(Doc->symbolMode) {
if(Doc->getSymbolMode()) {
// go into select modus to avoid placing a forbidden element
select->setChecked(true);
@ -3080,7 +3080,7 @@ void QucsApp::slotSymbolEdit()
// in a text document (e.g. VHDL)
if (isTextDocument (w)) {
TextDoc *TDoc = (TextDoc*)w;
if (!TDoc->DocName.endsWith(".va")) {
if (!TDoc->getDocName().endsWith(".va")) {
QMessageBox::warning(this,tr("Error"),
tr("Symbol editing supported only for schematics and Verilog-A documents!"));
return;
@ -3091,9 +3091,9 @@ void QucsApp::slotSymbolEdit()
"for more details."));
}
// set 'DataDisplay' document of text file to symbol file
QFileInfo Info(TDoc->DocName);
QFileInfo Info(TDoc->getDocName());
QString sym = Info.completeBaseName()+".sym";
TDoc->DataDisplay = sym;
TDoc->setDataDisplay(sym);
// symbol file already loaded?
int paint_mode = 0;
@ -3101,16 +3101,16 @@ void QucsApp::slotSymbolEdit()
paint_mode = 1;
// change current page to appropriate symbol file
slotChangePage(TDoc->DocName,TDoc->DataDisplay);
slotChangePage(TDoc->getDocName(),TDoc->getDataDisplay());
// set 'DataDisplay' document of symbol file to original text file
Schematic *SDoc = (Schematic*)DocumentTab->currentWidget();
SDoc->DataDisplay = Info.fileName();
SDoc->setDataDisplay(Info.fileName());
// change into symbol mode
if (paint_mode) // but only switch coordinates if newly loaded
SDoc->switchPaintMode();
SDoc->symbolMode = true;
SDoc->setSymbolMode(true);
changeSchematicSymbolMode(SDoc);
SDoc->becomeCurrent(true);
SDoc->viewport()->update();
@ -3118,7 +3118,7 @@ void QucsApp::slotSymbolEdit()
// in a normal schematic, symbol file
else {
Schematic *SDoc = (Schematic*)w;
if (!SDoc->isSymbolOnly) {
if (!SDoc->getIsSymbolOnly()) {
slotHideEdit(); // disable text edit of component property
SDoc->switchPaintMode(); // twist the view coordinates
changeSchematicSymbolMode(SDoc);
@ -3150,7 +3150,7 @@ void QucsApp::slotPowerMatching()
Dia->setTwoPortMatch(false); // will also cause the corresponding impedance LineEdit to be updated
Schematic *sch = dynamic_cast<Schematic*>(w);
if (sch->SimOpenDpl || sch->DocName.endsWith(".dpl")) {
if (sch->getSimOpenDpl() || sch->getDocName().endsWith(".dpl")) {
slotToPage();
}
if(Dia->exec() != QDialog::Accepted)
@ -3169,11 +3169,11 @@ void QucsApp::slot2PortMatching()
QString DataSet;
Schematic *Doc = (Schematic*)DocumentTab->currentWidget();
int z = pm->pGraph->Var.indexOf(':');
if(z <= 0) DataSet = Doc->DataSet;
if(z <= 0) DataSet = Doc->getDataSet();
else DataSet = pm->pGraph->Var.mid(z+1);
double Freq = pm->powFreq();
QFileInfo Info(Doc->DocName);
QFileInfo Info(Doc->getDocName());
DataSet = Info.path()+QDir::separator()+DataSet;
Diagram *Diag = new Diagram();
@ -3238,7 +3238,7 @@ void QucsApp::slot2PortMatching()
Dia->setS22LineEdits(S22real, S22imag);
Schematic *sch = dynamic_cast<Schematic*>(w);
if (sch->SimOpenDpl || sch->DocName.endsWith(".dpl")) {
if (sch->getSimOpenDpl() || sch->getDocName().endsWith(".dpl")) {
slotToPage();
}
if(Dia->exec() != QDialog::Accepted)
@ -3436,7 +3436,7 @@ void QucsApp::slotSimulateWithSpice()
if (!isTextDocument(DocumentTab->currentWidget())) {
Schematic *sch = (Schematic*)DocumentTab->currentWidget();
if (TuningMode) {
QFileInfo Info(sch->DocName);
QFileInfo Info(sch->getDocName());
QString ext = Info.suffix();
if (ext == "dpl") {
QucsDoc *Doc = (QucsDoc *)sch;
@ -3445,26 +3445,26 @@ void QucsApp::slotSimulateWithSpice()
}
}
if (sch->DocName.isEmpty()) {
auto biasState = sch->showBias;
if (sch->getDocName().isEmpty()) {
auto biasState = sch->getShowBias();
QMessageBox::warning(this,tr("Simulate schematic"),
tr("Schematic not saved! Simulation of unsaved schematic "
"not possible. Save schematic first!"));
slotFileSaveAs();
sch->showBias = biasState;
sch->setShowBias(biasState);
}
ExternSimDialog *SimDlg = new ExternSimDialog(sch);
connect(SimDlg,SIGNAL(simulated(ExternSimDialog*)),
this,SLOT(slotAfterSpiceSimulation(ExternSimDialog*)));
connect(SimDlg,SIGNAL(warnings()),this,SLOT(slotShowWarnings()));
connect(SimDlg,SIGNAL(success()),this,SLOT(slotResetWarnings()));
if (TuningMode || sch->showBias == 0) SimDlg->slotStart();
if (TuningMode || sch->getShowBias() == 0) SimDlg->slotStart();
else SimDlg->exec();
/*disconnect(SimDlg,SIGNAL(simulated()),this,SLOT(slotAfterSpiceSimulation()));
disconnect(SimDlg,SIGNAL(warnings()),this,SLOT(slotShowWarnings()));
disconnect(SimDlg,SIGNAL(success()),this,SLOT(slotResetWarnings()));*/
/*if (SimDlg->wasSimulated && sch->SimOpenDpl)
if (sch->showBias < 1) slotChangePage(sch->DocName,sch->DataDisplay);
/*if (SimDlg->wasSimulated && sch->getSimOpenDpl())
if (sch->getShowBias() < 1) slotChangePage(sch->getDocName(),sch->getDataDisplay());
delete SimDlg;*/
} else {
QMessageBox::warning(this,tr("Simulate schematic"),
@ -3499,16 +3499,16 @@ void QucsApp::slotAfterSpiceSimulation(ExternSimDialog *SimDlg)
return;
}
if (SimDlg->wasSimulated()) {
if(sch->SimOpenDpl) {
if (sch->showBias < 1) {
if(sch->getSimOpenDpl()) {
if (sch->getShowBias() < 1) {
if (!TuningMode) {
slotChangePage(sch->DocName,sch->DataDisplay);
} else if (!sch->DocName.endsWith(".dpl")) {
slotChangePage(sch->DocName,sch->DataDisplay);
slotChangePage(sch->getDocName(),sch->getDataDisplay());
} else if (!sch->getDocName().endsWith(".dpl")) {
slotChangePage(sch->getDocName(),sch->getDataDisplay());
}
}
} else {
if (sch->showBias < 1 && !TuningMode) {
if (sch->getShowBias() < 1 && !TuningMode) {
int idx = Category::getModulesNr (QObject::tr("diagrams"));
CompChoose->setCurrentIndex(idx); // switch to diagrams
slotSetCompView (idx);
@ -3518,15 +3518,15 @@ void QucsApp::slotAfterSpiceSimulation(ExternSimDialog *SimDlg)
sch->reloadGraphs();
sch->viewport()->update();
if(sch->SimRunScript) {
if(sch->getSimRunScript()) {
// run script
octave->startOctave();
octave->runOctaveScript(sch->Script);
octave->runOctaveScript(sch->getScript());
}
if (TuningMode) {
tunerDia->SimulationEnded();
}
if (sch->showBias>0 || QucsMain->TuningMode) SimDlg->close();
if (sch->getShowBias()>0 || QucsMain->TuningMode) SimDlg->close();
}
void QucsApp::slotBuildVAModule()
@ -3534,7 +3534,7 @@ void QucsApp::slotBuildVAModule()
if (!isTextDocument(DocumentTab->currentWidget())) {
Schematic *Sch = (Schematic*)DocumentTab->currentWidget();
QFileInfo inf(Sch->DocName);
QFileInfo inf(Sch->getDocName());
QString filename = QFileDialog::getSaveFileName(this,tr("Save Verilog-A module"),
inf.path()+QDir::separator()+"testmodule.va",
"Verilog-A (*.va)");
@ -3564,7 +3564,7 @@ void QucsApp::slotBuildVAModule()
if (!isTextDocument(DocumentTab->currentWidget())) {
Schematic *Sch = (Schematic*)DocumentTab->currentWidget();
QFileInfo inf(Sch->DocName);
QFileInfo inf(Sch->getDocName());
QString msg,ext;
switch(mode) {
@ -3590,7 +3590,7 @@ void QucsApp::slotBuildVAModule()
switch(mode) {
case spicecompat::cmgenSUBifs: r = cmgen->createIFS(stream,Sch);
case spicecompat::cmgenEDDifs: {
for(Component *pc = Sch->DocComps.first(); pc != 0; pc = Sch->DocComps.next()) {
for(Component *pc = Sch->a_DocComps.first(); pc != 0; pc = Sch->a_DocComps.next()) {
if (pc->isSelected) {
r = cmgen->createIFSfromEDD(stream,Sch,pc);
break;
@ -3599,7 +3599,7 @@ void QucsApp::slotBuildVAModule()
}
break;
case spicecompat::cmgenEDDmod : {
for(Component *pc = Sch->DocComps.first(); pc != 0; pc = Sch->DocComps.next()) {
for(Component *pc = Sch->a_DocComps.first(); pc != 0; pc = Sch->a_DocComps.next()) {
if (pc->isSelected) {
r = cmgen->createMODfromEDD(stream,Sch,pc);
break;

View File

@ -186,7 +186,7 @@ private slots:
void slotChangeView();
void slotAfterSimulation(int, SimMessage*);
void slotDCbias();
void slotChangePage(QString&, QString&);
void slotChangePage(const QString&, const QString&);
void slotHideEdit();
void slotFileChanged(bool);
void slotSimSettings();

View File

@ -236,8 +236,8 @@ void QucsApp::slotResetDiagramLimits()
// Now read in the data.
auto* Doc = (Schematic*)DocumentTab->currentWidget();
QFileInfo Info(Doc->DocName);
QString defaultDataSet = Info.absolutePath() + QDir::separator() + Doc->DataSet;
QFileInfo Info(Doc->getDocName());
QString defaultDataSet = Info.absolutePath() + QDir::separator() + Doc->getDataSet();
diagram->loadGraphData(defaultDataSet);
Doc->setChanged(true, true);
@ -502,7 +502,7 @@ void QucsApp::slotInsertPort(bool on)
delete view->selElem; // delete previously selected component
Schematic *Doc = (Schematic*)DocumentTab->currentWidget();
if (Doc->symbolMode) {
if (Doc->getSymbolMode()) {
view->selElem = new PortSymbol();
} else {
view->selElem = new SubCirPort();
@ -918,8 +918,8 @@ void QucsApp::slotCallRFLayout()
tr("Layouting of display pages is not supported!"));
return;
}
input_file = sch->DocName;
QFileInfo inf(sch->DocName);
input_file = sch->getDocName();
QFileInfo inf(sch->getDocName());
odir = inf.absolutePath();
netlist_file = inf.absolutePath() + QDir::separator()
+ inf.baseName() + ".net";
@ -932,7 +932,7 @@ void QucsApp::slotCallRFLayout()
QStringList Collect;
QPlainTextEdit *ErrText = new QPlainTextEdit(); //dummy
int pNum = sch->prepareNetlist(stream, Collect, ErrText);
if (!sch->isAnalog) {
if (!sch->getIsAnalog()) {
QMessageBox::critical(this, tr("Error"), tr("Digital schematic not supported!"));
return;
}
@ -1119,7 +1119,7 @@ void QucsApp::slotCursorLeft(bool left)
Doc->viewport()->update();
return;
} else { // random selection. move all of them
view->moveElements(&movingElements, sign*Doc->GridX, 0);
view->moveElements(&movingElements, sign*Doc->getGridX(), 0);
view->MAx3 = 1; // sign for moved elements
view->endElementMoving(Doc, &movingElements);
}
@ -1185,7 +1185,7 @@ void QucsApp::slotCursorUp(bool up)
Doc->viewport()->update();
return;
}else{ // some random selection, put it back
view->moveElements(&movingElements, 0, ((up)?-1:1) * Doc->GridY);
view->moveElements(&movingElements, 0, ((up)?-1:1) * Doc->getGridY());
view->MAx3 = 1; // sign for moved elements
view->endElementMoving(Doc, &movingElements);
}
@ -1199,7 +1199,7 @@ void QucsApp::slotApplyCompText()
{
QFont f = QucsSettings.font;
Schematic *Doc = (Schematic*)DocumentTab->currentWidget();
f.setPointSizeF( Doc->Scale * float(f.pointSize()) );
f.setPointSizeF( Doc->getScale() * float(f.pointSize()) );
editText->setFont(f);
Component *const component = dynamic_cast<Component*>(view->focusElement);
@ -1225,7 +1225,7 @@ void QucsApp::slotApplyCompText()
// TODO: rewrite with std::none_of after replacing Q3PtrList
// with modern container
bool is_unique = true;
for (auto* other : *Doc->Components) {
for (auto* other : *Doc->a_Components) {
if (other->Name == new_name) {
is_unique = false;
break;
@ -1328,10 +1328,10 @@ void QucsApp::slotImportData()
QString dname;
if (isTextDocument(DocumentTab->currentWidget())) {
TextDoc *doc = (TextDoc *)DocumentTab->currentWidget();
dname = doc->DocName;
dname = doc->getDocName();
} else {
Schematic *doc = (Schematic *)DocumentTab->currentWidget();
dname = doc->DocName;
dname = doc->getDocName();
}
QFileInfo inf(dname);
if (inf.exists()) {
@ -1598,7 +1598,7 @@ void QucsApp::slotBuildModule()
builder->setProcessChannelMode(QProcess::MergedChannels);
// get current va document
QucsDoc *Doc = getDoc();
QString vaModule = Doc->fileBase(Doc->DocName);
QString vaModule = Doc->fileBase(Doc->getDocName());
QString admsXml = QucsSettings.AdmsXmlBinDir.canonicalPath();
@ -1689,7 +1689,7 @@ void QucsApp::buildWithOpenVAF()
builder->setProcessChannelMode(QProcess::MergedChannels);
// get current va document
QucsDoc *Doc = getDoc();
QString vaModule = Doc->DocName;
QString vaModule = Doc->getDocName();
QString openVAF = QucsSettings.OpenVAFExecutable;

View File

@ -21,36 +21,41 @@
#include "qucs.h"
QucsDoc::QucsDoc(QucsApp *App_, const QString& Name_)
QucsDoc::QucsDoc(QucsApp *App_, const QString& Name_) :
a_DocName(Name_),
a_DataSet(),
a_DataDisplay(),
a_Script(),
a_SimTime(),
a_lastSaved(),
a_Scale(1.0),
a_App(App_),
a_DocChanged(false),
a_SimOpenDpl(false),
a_SimRunScript(false),
a_showBias(-1), // don't show DC bias (currently for "Schematic" only)
a_GridOn(true),
a_tmpPosX(0),
a_tmpPosY(0)
{
App = App_;
GridOn = true;
DocName = Name_;
QFileInfo Info(DocName);
if(!DocName.isEmpty()) {
DocName = Info.absoluteFilePath();
QFileInfo Info(a_DocName);
if(!a_DocName.isEmpty()) {
a_DocName = Info.absoluteFilePath();
QString base = Info.completeBaseName();
QString ext = Info.suffix();
if(ext == "m" || ext == "oct")
SimTime = "1";
a_SimTime = "1";
DataSet = base + ".dat"; // name of the default dataset
Script = base + ".m"; // name of the default script
a_DataSet = base + ".dat"; // name of the default dataset
a_Script = base + ".m"; // name of the default script
if(ext != "dpl")
DataDisplay = base + ".dpl"; // name of default data display
a_DataDisplay = base + ".dpl"; // name of default data display
else {
DataDisplay = base + ".sch"; // name of default schematic
GridOn = false; // data display without grid (per default)
a_DataDisplay = base + ".sch"; // name of default schematic
a_GridOn = false; // data display without grid (per default)
}
}
SimOpenDpl = false;
SimRunScript = false;
DocChanged = false;
showBias = -1; // don't show DC bias (currently for "Schematic" only)
Scale = 1.0;
}
QString QucsDoc::fileSuffix (const QString& Name) {
@ -59,7 +64,7 @@ QString QucsDoc::fileSuffix (const QString& Name) {
}
QString QucsDoc::fileSuffix (void) {
return fileSuffix (DocName);
return fileSuffix (a_DocName);
}
QString QucsDoc::fileBase (const QString& Name) {
@ -68,6 +73,6 @@ QString QucsDoc::fileBase (const QString& Name) {
}
QString QucsDoc::fileBase (void) {
return fileBase (DocName);
return fileBase (a_DocName);
}

View File

@ -45,21 +45,48 @@ public:
static QString fileBase (const QString&);
QString fileBase (void);
QString DocName;
QString DataSet; // name of the default dataset
QString DataDisplay; // name of the default data display
QString Script;
QString SimTime; // used for VHDL simulation, but stored in datadisplay
QDateTime lastSaved;
float getScale() const { return a_Scale; }
bool getDocChanged() const { return a_DocChanged; }
void setDocChanged(bool value) { a_DocChanged = value; }
bool getSimOpenDpl() const { return a_SimOpenDpl; }
void setSimOpenDpl(bool value) { a_SimOpenDpl = value; }
bool getSimRunScript() const { return a_SimRunScript; }
void setSimRunScript(bool value) { a_SimRunScript = value; }
bool getGridOn() const { return a_GridOn; }
void setGridOn(bool value) { a_GridOn = value; }
QucsApp* getApp() const { return a_App; }
int getShowBias() const { return a_showBias; }
void setShowBias(int value) { a_showBias = value; }
QString getDocName() const { return a_DocName; }
void setDocName(const QString& value) { a_DocName = value; }
QString getDataSet() const { return a_DataSet; }
void setDataSet(const QString& value) { a_DataSet = value; }
QString getDataDisplay() const { return a_DataDisplay; }
void setDataDisplay(const QString& value) { a_DataDisplay = value; }
QString getScript() const { return a_Script; }
void setScript(const QString& value) { a_Script = value; }
QString getSimTime() const { return a_SimTime; }
void setSimTime(const QString& value) { a_SimTime = value; }
QDateTime getLastSaved() const { return a_lastSaved; }
void setLastSaved(const QDateTime& value) { a_lastSaved = value; }
float Scale;
QucsApp *App;
bool DocChanged;
bool SimOpenDpl; // open data display after simulation ?
bool SimRunScript; // run script after simulation ?
int showBias; // -1=no, 0=calculation running, >0=show DC bias points
bool GridOn;
int tmpPosX, tmpPosY;
protected:
QString a_DocName;
QString a_DataSet; // name of the default dataset
QString a_DataDisplay; // name of the default data display
QString a_Script;
QString a_SimTime; // used for VHDL simulation, but stored in datadisplay
QDateTime a_lastSaved;
float a_Scale;
QucsApp* a_App;
bool a_DocChanged;
bool a_SimOpenDpl; // open data display after simulation ?
bool a_SimRunScript; // run script after simulation ?
int a_showBias; // -1=no, 0=calculation running, >0=show DC bias points
bool a_GridOn;
int a_tmpPosX;
int a_tmpPosY;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -76,6 +76,7 @@ typedef QMap<QString, SubFile> SubMap;
class Schematic : public Q3ScrollView, public QucsDoc {
Q_OBJECT
public:
Schematic(QucsApp*, const QString&);
~Schematic();
@ -191,22 +192,57 @@ public:
bool checkDplAndDatNames();
/*! \brief Get (schematic) file reference */
QFileInfo getFileInfo (void) { return a_FileInfo; }
/*! \brief Set reference to file (schematic) */
void setFileInfo(QString FileName) { a_FileInfo = QFileInfo(FileName); }
QString getFrame_Text0() const { return a_Frame_Text0; }
void setFrame_Text0(const QString value) { a_Frame_Text0 = value; }
QString getFrame_Text1() const { return a_Frame_Text1; }
void setFrame_Text1(const QString value) { a_Frame_Text1 = value; }
QString getFrame_Text2() const { return a_Frame_Text2; }
void setFrame_Text2(const QString value) { a_Frame_Text2 = value; }
QString getFrame_Text3() const { return a_Frame_Text3; }
void setFrame_Text3(const QString value) { a_Frame_Text3 = value; }
int getShowFrame() const { return a_showFrame; }
void setShowFrame(int value) { a_showFrame = value; }
int getViewX1() const { return a_ViewX1; }
int getViewY1() const { return a_ViewY1; }
int getGridX() const { return a_GridX; }
void setGridX(int value) { a_GridX = value; }
int getGridY() const { return a_GridY; }
void setGridY(int value) { a_GridY = value; }
bool getSymbolMode() const { return a_symbolMode; }
void setSymbolMode(bool value) { a_symbolMode = value; }
bool getIsSymbolOnly() const { return a_isSymbolOnly; }
void setIsSymbolOnly(bool value) { a_isSymbolOnly = value; }
void clearPostedPaintEvents() { a_PostedPaintEvents.clear(); }
// The pointers points to the current lists, either to the schematic
// elements "Doc..." or to the symbol elements "SymbolPaints".
Q3PtrList<Wire> *Wires, DocWires;
Q3PtrList<Node> *Nodes, DocNodes;
Q3PtrList<Diagram> *Diagrams, DocDiags;
Q3PtrList<Painting> *Paintings, DocPaints;
Q3PtrList<Component> *Components, DocComps;
Q3PtrList<Wire> *a_Wires;
Q3PtrList<Wire> a_DocWires;
Q3PtrList<Node>* a_Nodes;
Q3PtrList<Node> a_DocNodes;
Q3PtrList<Diagram>* a_Diagrams;
Q3PtrList<Diagram> a_DocDiags;
Q3PtrList<Painting>* a_Paintings;
Q3PtrList<Painting> a_DocPaints;
Q3PtrList<Component>* a_Components;
Q3PtrList<Component> a_DocComps;
Q3PtrList<Painting> SymbolPaints; // symbol definition for subcircuit
Q3PtrList<Painting> a_SymbolPaints; // symbol definition for subcircuit
QList<PostedPaintEvent> PostedPaintEvents;
bool symbolMode; // true if in symbol painting mode
bool isSymbolOnly;
private:
QList<PostedPaintEvent> a_PostedPaintEvents;
bool a_symbolMode; // true if in symbol painting mode
bool a_isSymbolOnly;
// Horizontal and vertical grid step
int GridX, GridY;
int a_GridX;
int a_GridY;
// Variables View* are the coordinates of top-level and bottom-right corners
// of a rectangle representing the schematic "model". This
@ -215,26 +251,33 @@ public:
// inside this rectangle. The size of this rectangle is the "logical" size
// of the schematic. The comment in "renderModel" method describes how
// these variables ("model") is used to draw the scematic.
int ViewX1, ViewY1, ViewX2, ViewY2;
int a_ViewX1;
int a_ViewY1;
int a_ViewX2;
int a_ViewY2;
int showFrame;
QString Frame_Text0, Frame_Text1, Frame_Text2, Frame_Text3;
int a_showFrame;
QString a_Frame_Text0;
QString a_Frame_Text1;
QString a_Frame_Text2;
QString a_Frame_Text3;
// Two of those data sets are needed for Schematic and for symbol.
// Which one is in "tmp..." depends on "symbolMode".
float tmpScale;
int tmpViewX1, tmpViewY1, tmpViewX2, tmpViewY2;
int tmpUsedX1, tmpUsedY1, tmpUsedX2, tmpUsedY2;
float a_tmpScale;
int a_tmpViewX1;
int a_tmpViewY1;
int a_tmpViewX2;
int a_tmpViewY2;
int a_tmpUsedX1;
int a_tmpUsedY1;
int a_tmpUsedX2;
int a_tmpUsedY2;
int undoActionIdx;
QVector<QString *> undoAction;
int undoSymbolIdx;
QVector<QString *> undoSymbol; // undo stack for circuit symbol
/*! \brief Get (schematic) file reference */
QFileInfo getFileInfo (void) { return FileInfo; }
/*! \brief Set reference to file (schematic) */
void setFileInfo(QString FileName) { FileInfo = QFileInfo(FileName); }
int a_undoActionIdx;
QVector<QString *> a_undoAction;
int a_undoSymbolIdx;
QVector<QString *> a_undoSymbol; // undo stack for circuit symbol
signals:
void signalCursorPosChanged(int, int, QString);
@ -267,27 +310,30 @@ private:
// Variables Used* hold the coordinates of top-left and bottom-right corners
// of a smallest rectangle which can fit all elements of the schematic.
// This rectangle exists in the same coordinate system as View*-rectangle
int UsedX1, UsedY1, UsedX2, UsedY2;
int a_UsedX1;
int a_UsedY1;
int a_UsedX2;
int a_UsedY2;
void sizeOfAll(int&, int&, int&, int&);
// Viewport-realative coordinates of the cursor between mouse movements.
// Used in "pan with mouse" feature.
QPoint previousCursorPosition;
QPoint a_previousCursorPosition;
bool dragIsOkay;
bool a_dragIsOkay;
/*! \brief hold system-independent information about a schematic file */
QFileInfo FileInfo;
QFileInfo a_FileInfo;
/**
Minimum scale at which schematic could be drawn.
*/
static constexpr double minScale = 0.1;
static constexpr double a_minScale = 0.1;
/**
Maximum scale at which schematic could be drawn.
*/
static constexpr double maxScale = 10.0;
static constexpr double a_maxScale = 10.0;
/**
Returns a rectangle which describes the model plane of the schematic.
@ -462,6 +508,11 @@ public:
void clearSignalsAndFileList();
void clearSignals();
void setIsAnalog(bool value) { a_isAnalog = value; }
bool getIsAnalog() const { return a_isAnalog; }
void setIsVerilog(bool value) { a_isVerilog = value; }
bool getIsVerilog() const { return a_isVerilog; }
private:
int saveDocument();
@ -491,14 +542,12 @@ private:
void endNetlistDigital(QTextStream &);
bool throughAllComps(QTextStream *, int&, QStringList&, QPlainTextEdit *, int);
DigMap Signals; // collecting node names for VHDL signal declarations
QStringList PortTypes;
public:
bool isAnalog;
bool isVerilog;
bool creatingLib;
DigMap a_Signals; // collecting node names for VHDL signal declarations
QStringList a_PortTypes;
bool a_isAnalog;
bool a_isVerilog;
bool a_creatingLib;
};
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -57,7 +57,7 @@
QRect Schematic::modelRect()
{
return QRect{ViewX1, ViewY1, ViewX2 - ViewX1, ViewY2 - ViewY1};
return QRect{a_ViewX1, a_ViewY1, a_ViewX2 - a_ViewX1, a_ViewY2 - a_ViewY1};
}
QRect Schematic::viewportRect() {
@ -91,17 +91,17 @@ QPoint Schematic::contentsToModel(const QPoint& coordinates)
// in model plane
// QPoint overrides operator /. It divides both coordinates on given value
QPoint modelCoords = coordinates / Scale;
QPoint modelCoords = coordinates / a_Scale;
modelCoords.setX(ViewX1 + modelCoords.x());
modelCoords.setY(ViewY1 + modelCoords.y());
modelCoords.setX(a_ViewX1 + modelCoords.x());
modelCoords.setY(a_ViewY1 + modelCoords.y());
return modelCoords;
}
QPoint Schematic::modelToContents(const QPoint& coordinates)
{
// Model and contents sizes are interconnected and obey the rule:
// <size on model plane> * <Scale> = <size on contents>
// <size on model plane> * <a_Scale> = <size on contents>
//
// Contents is a rectangle with (0, 0) at its top-left corner. Model plane
// is rectangular area of abstract infinite plane, so model plane's top-left
@ -114,17 +114,17 @@ QPoint Schematic::modelToContents(const QPoint& coordinates)
// 2. Adjust resulting coordinates so thay they become having the same scale
// as contents
QPoint contentsCoords{coordinates.x() - ViewX1, coordinates.y() - ViewY1};
contentsCoords *= Scale;
QPoint contentsCoords{coordinates.x() - a_ViewX1, coordinates.y() - a_ViewY1};
contentsCoords *= a_Scale;
return contentsCoords;
}
double Schematic::clipScale(double offeredScale)
{
if (offeredScale > maxScale) {
return maxScale;
} else if (offeredScale < minScale) {
return minScale;
if (offeredScale > a_maxScale) {
return a_maxScale;
} else if (offeredScale < a_minScale) {
return a_minScale;
} else {
return offeredScale;
}
@ -134,7 +134,7 @@ bool Schematic::shouldRender(const double& newScale, const QRect& newModelBounds
const QRect currentModelBounds = modelRect();
// This point currently displayed at "viewportCoords" of the viewport
const QPoint currenlyDisplayed = viewportToModel(viewportCoords);
return Scale != newScale || toBeDisplayed != currenlyDisplayed || currentModelBounds != newModelBounds;
return a_Scale != newScale || toBeDisplayed != currenlyDisplayed || currentModelBounds != newModelBounds;
}
double Schematic::renderModel(const double offeredScale, QRect newModel, const QPoint modelPoint, const QPoint viewportPoint)
@ -151,7 +151,7 @@ double Schematic::renderModel(const double offeredScale, QRect newModel, const Q
// Maybe there is no need to do anything
const double newScale = clipScale(offeredScale);
if (!shouldRender(newScale, newModel, modelPoint, viewportPoint)) {
return Scale;
return a_Scale;
}
// The part below is quite tricky: while working at the model plane scale,
@ -176,19 +176,19 @@ double Schematic::renderModel(const double offeredScale, QRect newModel, const Q
// At this point everything is ready for rendering and positioning
// Set new model size
ViewX1 = newModel.left();
ViewY1 = newModel.top();
ViewX2 = newModel.left() + newModel.width();
ViewY2 = newModel.top() + newModel.height();
a_ViewX1 = newModel.left();
a_ViewY1 = newModel.top();
a_ViewX2 = newModel.left() + newModel.width();
a_ViewY2 = newModel.top() + newModel.height();
Scale = newScale;
resizeContents(static_cast<int>(std::round(newModel.width() * Scale)),
static_cast<int>(std::round(newModel.height() * Scale)));
a_Scale = newScale;
resizeContents(static_cast<int>(std::round(newModel.width() * a_Scale)),
static_cast<int>(std::round(newModel.height() * a_Scale)));
auto contentTopLeft = modelToContents(vpTopLeftOnModelPlane);
setContentsPos(contentTopLeft.x(), contentTopLeft.y());
viewport()->update();
return Scale;
return a_Scale;
}

View File

@ -51,7 +51,7 @@ TextDoc::TextDoc(QucsApp *App_, const QString& Name_) : QPlainTextEdit(), QucsDo
SetChanged = false;
devtype = DEV_DEF;
tmpPosX = tmpPosY = 1; // set to 1 to trigger line highlighting
a_tmpPosX = a_tmpPosY = 1; // set to 1 to trigger line highlighting
setLanguage (Name_);
viewport()->setFocus();
@ -125,14 +125,14 @@ void TextDoc::setLanguage (int lang)
*/
bool TextDoc::saveSettings (void)
{
QFile file (DocName + ".cfg");
QFile file (a_DocName + ".cfg");
if (!file.open (QIODevice::WriteOnly))
return false;
QTextStream stream (&file);
stream << "Textfile settings file, Qucs " PACKAGE_VERSION "\n"
<< "Simulation=" << simulation << "\n"
<< "Duration=" << SimTime << "\n"
<< "Duration=" << a_SimTime << "\n"
<< "Module=" << (!simulation) << "\n"
<< "Library=" << Library << "\n"
<< "Libraries=" << Libraries << "\n"
@ -153,7 +153,7 @@ bool TextDoc::saveSettings (void)
*/
bool TextDoc::loadSettings (void)
{
QFile file (DocName + ".cfg");
QFile file (a_DocName + ".cfg");
if (!file.open (QIODevice::ReadOnly))
return false;
@ -168,7 +168,7 @@ bool TextDoc::loadSettings (void)
if (Setting == "Simulation") {
simulation = Line.toInt (&ok);
} else if (Setting == "Duration") {
SimTime = Line;
a_SimTime = Line;
} else if (Setting == "Module") {
} else if (Setting == "Library") {
Library = Line;
@ -197,15 +197,15 @@ bool TextDoc::loadSettings (void)
*/
void TextDoc::setName (const QString& Name_)
{
DocName = Name_;
setLanguage (DocName);
a_DocName = Name_;
setLanguage (a_DocName);
QFileInfo Info (DocName);
QFileInfo Info (a_DocName);
DataSet = Info.baseName () + ".dat";
DataDisplay = Info.baseName () + ".dpl";
a_DataSet = Info.baseName () + ".dat";
a_DataDisplay = Info.baseName () + ".dpl";
if(Info.suffix() == "m" || Info.suffix() == "oct")
SimTime = "1";
a_SimTime = "1";
}
/*!
@ -222,32 +222,32 @@ void TextDoc::becomeCurrent (bool)
emit signalRedoState(document()->isRedoAvailable());
// update appropriate menu entries
App->symEdit->setText (tr("Edit Text Symbol"));
App->symEdit->setStatusTip (tr("Edits the symbol for this text document"));
App->symEdit->setWhatsThis (
a_App->symEdit->setText (tr("Edit Text Symbol"));
a_App->symEdit->setStatusTip (tr("Edits the symbol for this text document"));
a_App->symEdit->setWhatsThis (
tr("Edit Text Symbol\n\nEdits the symbol for this text document"));
if (language == LANG_VHDL) {
App->insEntity->setText (tr("VHDL entity"));
App->insEntity->setStatusTip (tr("Inserts skeleton of VHDL entity"));
App->insEntity->setWhatsThis (
a_App->insEntity->setText (tr("VHDL entity"));
a_App->insEntity->setStatusTip (tr("Inserts skeleton of VHDL entity"));
a_App->insEntity->setWhatsThis (
tr("VHDL entity\n\nInserts the skeleton of a VHDL entity"));
}
else if (language == LANG_VERILOG || language == LANG_VERILOGA) {
App->insEntity->setText (tr("Verilog module"));
App->insEntity->setStatusTip (tr("Inserts skeleton of Verilog module"));
App->insEntity->setWhatsThis (
a_App->insEntity->setText (tr("Verilog module"));
a_App->insEntity->setStatusTip (tr("Inserts skeleton of Verilog module"));
a_App->insEntity->setWhatsThis (
tr("Verilog module\n\nInserts the skeleton of a Verilog module"));
App->buildModule->setEnabled(true);
a_App->buildModule->setEnabled(true);
}
else if (language == LANG_OCTAVE) {
App->insEntity->setText (tr("Octave function"));
App->insEntity->setStatusTip (tr("Inserts skeleton of Octave function"));
App->insEntity->setWhatsThis (
a_App->insEntity->setText (tr("Octave function"));
a_App->insEntity->setStatusTip (tr("Inserts skeleton of Octave function"));
a_App->insEntity->setWhatsThis (
tr("Octave function\n\nInserts the skeleton of a Octave function"));
}
App->simulate->setEnabled (true);
App->editActivate->setEnabled (true);
a_App->simulate->setEnabled (true);
a_App->editActivate->setEnabled (true);
}
bool TextDoc::baseSearch(const QString &str, bool CaseSensitive, bool wordOnly, bool backward)
@ -320,8 +320,8 @@ void TextDoc::slotCursorPosChanged()
int x = pos.blockNumber();
int y = pos.columnNumber();
emit signalCursorPosChanged(x+1, y+1, "");
tmpPosX = x;
tmpPosY = y;
a_tmpPosX = x;
a_tmpPosY = y;
}
/*!
@ -329,13 +329,13 @@ void TextDoc::slotCursorPosChanged()
*/
void TextDoc::slotSetChanged()
{
if((document()->isModified() && !DocChanged) || SetChanged) {
DocChanged = true;
if((document()->isModified() && !a_DocChanged) || SetChanged) {
a_DocChanged = true;
}
else if((!document()->isModified() && DocChanged)) {
DocChanged = false;
else if((!document()->isModified() && a_DocChanged)) {
a_DocChanged = false;
}
emit signalFileChanged(DocChanged);
emit signalFileChanged(a_DocChanged);
emit signalUndoState(document()->isUndoAvailable());
emit signalRedoState(document()->isRedoAvailable());
}
@ -352,7 +352,7 @@ QMenu *TextDoc::createStandardContextMenu()
QMenu *popup = QPlainTextEdit::createStandardContextMenu();
if (language != LANG_OCTAVE) {
((QWidget *) popup)->addAction(App->fileSettings);
((QWidget *) popup)->addAction(a_App->fileSettings);
}
return popup;
}
@ -363,19 +363,19 @@ QMenu *TextDoc::createStandardContextMenu()
*/
bool TextDoc::load ()
{
QFile file (DocName);
QFile file (a_DocName);
if (!file.open (QIODevice::ReadOnly))
return false;
setLanguage (DocName);
setLanguage (a_DocName);
QTextStream stream (&file);
insertPlainText(stream.readAll());
document()->setModified(false);
slotSetChanged ();
file.close ();
lastSaved = QDateTime::currentDateTime ();
a_lastSaved = QDateTime::currentDateTime ();
loadSettings ();
SimOpenDpl = simulation ? true : false;
a_SimOpenDpl = simulation ? true : false;
refreshLanguage();
return true;
}
@ -389,10 +389,10 @@ int TextDoc::save ()
{
saveSettings ();
QFile file (DocName);
QFile file (a_DocName);
if (!file.open (QIODevice::WriteOnly))
return -1;
setLanguage (DocName);
setLanguage (a_DocName);
QTextStream stream (&file);
stream << toPlainText();
@ -400,8 +400,8 @@ int TextDoc::save ()
slotSetChanged ();
file.close ();
QFileInfo Info (DocName);
lastSaved = Info.lastModified ();
QFileInfo Info (a_DocName);
a_lastSaved = Info.lastModified ();
/// clear highlighted lines on save \see MessageDock::slotCursor()
QList<QTextEdit::ExtraSelection> extraSelections;
@ -441,14 +441,14 @@ void TextDoc::showNoZoom()
}
/*!
* \brief TextDoc::loadSimulationTime set SimTime member variable
* \brief TextDoc::loadSimulationTime set a_SimTime member variable
* \param Time string with simulation time
* \return true if SimTime is set
* \return true if a_SimTime is set
*/
bool TextDoc::loadSimulationTime(QString& Time)
{
if(!SimTime.isEmpty()) {
Time = SimTime;
if(!a_SimTime.isEmpty()) {
Time = a_SimTime;
return true;
}
return false;
@ -550,7 +550,7 @@ QString TextDoc::getModuleName (void)
}
case LANG_OCTAVE:
{
QFileInfo Info (DocName);
QFileInfo Info (a_DocName);
return Info.baseName ();
}
default:
@ -603,7 +603,7 @@ void TextDoc::highlightCurrentLine()
void TextDoc::refreshLanguage()
{
this->setLanguage(DocName);
this->setLanguage(a_DocName);
syntaxHighlight->setLanguage(language);
syntaxHighlight->setDocument(document());
}