*** empty log message ***

This commit is contained in:
margraf 2006-04-18 06:03:52 +00:00
parent 4cf5821ce9
commit 3c4e6e25aa
28 changed files with 847 additions and 321 deletions

View File

@ -63,7 +63,23 @@ To display the result of this simulation type, there is the diagram
row by row in one diagram. So, let's have fun...
<br>
<br>
<h3>VHDL File Component</h3>
More complex and more universal simulations can be performed using the
component "VHDL file". This component can be picked up from the component
list view (section "digital components"). Nevertheless the recommended
usage is the following: The VHDL file should be a member of the project.
Then go to the content list view and click on the file name. After entering
the schematic area, the VHDL component can be placed.<br>
The last entity block in the VHDL file defines the interface, that is, all
input and output ports must be declared here. These ports are also shown by the
schematic symbol and can be connected to the rest of the circuit. During
simulation the source code of the VHDL file is placed into the top-level
VHDL file. This must be considered as it causes some limitations. For
example, the entity names within the VHDL file must differ from names
already given to subcircuits. (After a simulation, the complete source
code can be seen by pressing F6. Use it to get a feeling for this procedure.)
<br><a href="#top">back to the top</a><br>
<br><br><a href="#top">back to the top</a><br>
</body>
</html>

View File

@ -1,3 +1,13 @@
2006-04-15 Michael Margraf <michael.margraf@alumni.tu-berlin.de>
* mark current line in text editor
* new action: insert sceleton of VHDL entity
* bugfix: take care of deactivated components in subcircuits
* new component: VHDL file
* match text position after change of component symbol
* component name can be shown or not on schematic
* catch if user adds an equation line with already existing name
2006-04-08 Michael Margraf <michael.margraf@alumni.tu-berlin.de>
* compiling with "no-exceptions" reduces binary by a third

BIN
qucs/bitmaps/vhdlfile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 380 B

View File

@ -34,7 +34,7 @@ libcomponents_a_SOURCES = phaseshifter.cpp gyrator.cpp componentdialog.cpp \
ac_sim.cpp volt_dc.cpp volt_ac.cpp subcircuit.cpp sparamfile.cpp \
source_ac.cpp isolator.cpp equation.cpp circulator.cpp attenuator.cpp \
ampere_dc.cpp transformer.cpp symtrafo.cpp subcirport.cpp ground.cpp \
dcfeed.cpp dcblock.cpp biast.cpp inductor.cpp capacitor.cpp \
dcfeed.cpp dcblock.cpp biast.cpp inductor.cpp capacitor.cpp vhdlfile.cpp \
component.cpp resistor.cpp iprobe.cpp volt_noise.cpp ampere_noise.cpp \
msmbend.cpp msopen.cpp ampere_ac.cpp bjt.cpp jfet.cpp mosfet.cpp \
msgap.cpp bjtsub.cpp mosfet_sub.cpp vpulse.cpp ipulse.cpp vrect.cpp \
@ -54,7 +54,7 @@ noinst_HEADERS = $(MOCHEADERS) resistor.h components.h capacitor.h vccs.h \
source_ac.h sparamfile.h subcircuit.h volt_ac.h volt_dc.h ac_sim.h cccs.h \
ccvs.h coplanar.h dc_sim.h diode.h hb_sim.h mscorner.h mscoupled.h \
mscross.h msline.h msstep.h mstee.h param_sweep.h sp_sim.h substrate.h \
tline.h tr_sim.h component.h vcvs.h gyrator.h phaseshifter.h \
tline.h tr_sim.h component.h vcvs.h gyrator.h phaseshifter.h vhdlfile.h \
iprobe.h volt_noise.h ampere_noise.h msmbend.h msopen.h ampere_ac.h bjt.h \
jfet.h mosfet.h msgap.h bjtsub.h mosfet_sub.h vpulse.h ipulse.h vrect.h \
irect.h msvia.h amplifier.h opamp.h spicefile.h cpwopen.h cpwshort.h \

View File

@ -46,7 +46,7 @@ Component::Component()
mirroredX = false;
rotated = 0;
isSelected = false;
isActive = true;
isActive = showName = true;
cx = 0;
cy = 0;
@ -80,19 +80,25 @@ void Component::Bounding(int& _x1, int& _y1, int& _x2, int& _y2)
// -------------------------------------------------------
// Size of component text.
void Component::TextSize(int& _dx, int& _dy)
int Component::textSize(int& _dx, int& _dy)
{
QFontMetrics metrics(QucsSettings.font); // get size of text
int tmp;
_dx = metrics.width(Name);
_dy = metrics.height(); // for "Name"
int tmp, count=0;
_dx = _dy = 0;
if(showName) {
_dx = metrics.width(Name);
_dy = metrics.height();
count++;
}
for(Property *pp = Props.first(); pp != 0; pp = Props.next())
if(pp->display) {
// get width of text
tmp = metrics.width(pp->Name+"="+pp->Value);
if(tmp > _dx) _dx = tmp;
_dy += metrics.height();
count++;
}
return count;
}
// -------------------------------------------------------
@ -108,21 +114,11 @@ void Component::entireBounds(int& _x1, int& _y1, int& _x2, int& _y2, float Corr)
if(tx < x1) _x1 = tx+cx;
if(ty < y1) _y1 = ty+cy;
QFontMetrics metrics(QucsSettings.font);
QSize r = metrics.size(0, Name);
if((tx+r.width()) > x2) _x2 = tx+r.width()+cx;
if((ty+r.height()) > y2) _y2 = ty+r.height()+cy;
int dx, dy, ny;
ny = textSize(dx, dy);
dy = int(float(ny) / Corr); // correction for unproportional font scaling
int dy=1; // due to 'Name' text
for(Property *pp = Props.first(); pp != 0; pp = Props.next())
if(pp->display) {
// get width of text
r = metrics.size(0, pp->Name+"="+pp->Value);
if((tx+r.width()) > x2) _x2 = tx+r.width()+cx;
dy++;
}
dy = int(float(dy) / Corr); // correction for unproportional font scaling
if((tx+dx) > x2) _x2 = tx+dx+cx;
if((ty+dy) > y2) _y2 = ty+dy+cy;
}
@ -150,18 +146,21 @@ int Component::getTextSelected(int x_, int y_, float Corr)
x_ -= tx;
y_ -= ty;
int w, dy = int(float(y_) * Corr); // correction for font scaling
QFontMetrics metrics(QucsSettings.font);
int w = metrics.width(Name);
int dy = int(float(y_) * Corr); // correction for font scaling
if(dy < 1) {
if(x_ < w) return 0;
return -1;
if(showName) {
w = metrics.width(Name);
if(dy < 1) {
if(x_ < w) return 0;
return -1;
}
dy--;
}
Property *pp;
for(pp = Props.first(); pp != 0; pp = Props.next())
if(pp->display)
if((--dy) < 1) break;
if((dy--) < 1) break;
if(!pp) return -1;
// get width of text
@ -269,12 +268,15 @@ void Component::paint(ViewPainter *p)
p->Painter->setPen(QPen(QPen::black,1));
p->map(cx+tx, cy+ty, x, y);
p->Painter->drawText(x, y, 0, 0, Qt::DontClip, Name);
if(showName) {
p->Painter->drawText(x, y, 0, 0, Qt::DontClip, Name);
y += p->LineSpacing;
}
// write all properties
for(Property *p4 = Props.first(); p4 != 0; p4 = Props.next())
if(p4->display) {
y += p->LineSpacing;
p->Painter->drawText(x, y, 0, 0, Qt::DontClip, p4->Name+"="+p4->Value);
y += p->LineSpacing;
}
if(!isActive) {
@ -441,8 +443,11 @@ void Component::rotate()
tx = ty;
ty = tmp;
QFontMetrics metrics(QucsSettings.font); // get size of text
dx = metrics.width(Name);
dy = metrics.lineSpacing();
dx = dy = 0;
if(showName) {
dx = metrics.width(Name);
dy = metrics.lineSpacing();
}
for(Property *pp = Props.first(); pp != 0; pp = Props.next())
if(pp->display) {
// get width of text
@ -506,7 +511,9 @@ void Component::mirrorX()
y1 = -y2; y2 = -tmp; // mirror boundings
QFontMetrics metrics(QucsSettings.font); // get size of text
int dy = metrics.lineSpacing(); // for "Name"
int dy = 0;
if(showName)
dy = metrics.lineSpacing(); // for "Name"
for(Property *pp = Props.first(); pp != 0; pp = Props.next())
if(pp->display) dy += metrics.lineSpacing();
if((tx > x1) && (tx < x2)) ty = -ty-dy; // mirror text position
@ -563,7 +570,9 @@ void Component::mirrorY()
x1 = -x2; x2 = -tmp; // mirror boundings
QFontMetrics metrics(QucsSettings.font); // get size of text
int dx = metrics.width(Name);
int dx = 0;
if(showName)
dx = metrics.width(Name);
for(Property *pp = Props.first(); pp != 0; pp = Props.next())
if(pp->display) {
// get width of text
@ -616,11 +625,15 @@ QString Component::save()
{
QString s = "<" + Model;
if(Name.isEmpty()) s += " *";
else s += " "+Name;
if(Name.isEmpty()) s += " * ";
else s += " "+Name+" ";
if(isActive) s += " 1";
else s += " 0";
int i=0;
if(!showName)
i = 2;
if(isActive)
i |= 1;
s += QString::number(i);
s += " "+QString::number(cx)+" "+QString::number(cy);
s += " "+QString::number(tx)+" "+QString::number(ty);
if(mirroredX) s += " 1";
@ -655,9 +668,16 @@ bool Component::load(const QString& _s)
if(Name == "*") Name = "";
n = s.section(' ',2,2); // isActive
if(n.toInt(&ok) == 1) isActive = true;
else isActive = false;
tmp = n.toInt(&ok);
if(!ok) return false;
if(tmp & 1)
isActive = true;
else
isActive = false;
if(tmp & 2)
showName = false;
else
showName = true;
n = s.section(' ',3,3); // cx
cx = n.toInt(&ok);
@ -1262,6 +1282,7 @@ Component* getComponentFromName(QString& Line)
else if(cstr == "pulse") c = new vPulse();
else if(cstr == "rect") c = new vRect();
else if(cstr == "Vnoise") c = new Noise_vv();
else if(cstr == "HDL") c = new VHDL_File();
break;
case 'T' : if(cstr == "r") c = new Transformer();
else if(cstr == "LIN") c = new TLine();

View File

@ -44,7 +44,7 @@ public:
void print(ViewPainter*);
void setCenter(int, int, bool relative=false);
void getCenter(int&, int&);
void TextSize(int&, int&);
int textSize(int&, int&);
void Bounding(int&, int&, int&, int&);
void entireBounds(int&, int&, int&, int&, float);
bool getSelected(int, int);
@ -70,6 +70,7 @@ public:
bool isActive; // should it be used in simulation or not ?
int tx, ty; // upper left corner of text (position)
QString Description;
bool showName;
QString Model, Name;
protected:

View File

@ -20,13 +20,14 @@
#include "qucs.h"
#include "schematic.h"
#include <qlayout.h>
#include <qhbox.h>
#include <qvbox.h>
#include <qmessagebox.h>
#include <qlayout.h>
#include <qhgroupbox.h>
#include <qvalidator.h>
#include <qfiledialog.h>
#include <qtabwidget.h>
#include <qmessagebox.h>
#include <qfiledialog.h>
#include <math.h>
@ -41,7 +42,7 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d)
QString s;
all = new QVBoxLayout(this); // to provide neccessary size
QGridLayout *gp2;
QGridLayout *gp1;
QWidget *myParent = this;
ValInteger = new QIntValidator(1, 1000000, this);
@ -226,64 +227,64 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d)
QWidget *Tab2 = new QWidget(t);
t->addTab(Tab2, tr("Properties"));
gp2 = new QGridLayout(Tab2, 9,2,5,5);
gp1 = new QGridLayout(Tab2, 9,2,5,5);
myParent = Tab2;
}
else { // no simulation component
gp2 = new QGridLayout(0, 9,2,5,5);
all->addLayout(gp2);
gp1 = new QGridLayout(0, 9,2,5,5);
all->addLayout(gp1);
}
// ...........................................................
gp2->addMultiCellWidget(new QLabel(Comp->Description, myParent), 0,0,0,1);
gp1->addMultiCellWidget(new QLabel(Comp->Description, myParent), 0,0,0,1);
QHBox *h5 = new QHBox(myParent);
h5->setSpacing(5);
gp2->addWidget(h5, 1,0);
gp1->addWidget(h5, 1,0);
new QLabel(tr("Name:"), h5);
CompNameEdit = new QLineEdit(h5);
CompNameEdit->setValidator(ValRestrict);
connect(CompNameEdit, SIGNAL(returnPressed()), SLOT(slotButtOK()));
prop = new QListView(myParent);
showName = new QCheckBox(tr("display in schematic"), myParent);
gp1->addWidget(showName, 1,1);
QHGroupBox *PropertyBox = new QHGroupBox(tr("Properties"), myParent);
gp1->addMultiCellWidget(PropertyBox, 2,2,0,1);
prop = new QListView(PropertyBox);
prop->setMinimumSize(200, 150);
prop->addColumn(tr("Name"));
prop->addColumn(tr("Value"));
prop->addColumn(tr("display"));
prop->addColumn(tr("Description"));
prop->setSorting(-1); // no sorting
gp2->addMultiCellWidget(prop, 2,8,0,0);
Name = new QLabel(myParent);
gp2->addWidget(Name, 2,1);
QVBox *v1 = new QVBox(PropertyBox);
Description = new QLabel(myParent);
gp2->addWidget(Description, 3,1);
Name = new QLabel(v1);
Description = new QLabel(v1);
// hide, because it only replaces 'Description' in some cases
NameEdit = new QLineEdit(myParent);
NameEdit = new QLineEdit(v1);
NameEdit->setShown(false);
NameEdit->setValidator(ValRestrict);
gp2->addWidget(NameEdit, 3,1);
connect(NameEdit, SIGNAL(returnPressed()), SLOT(slotApplyPropName()));
edit = new QLineEdit(myParent);
edit = new QLineEdit(v1);
edit->setMinimumWidth(150);
gp2->addWidget(edit, 4,1);
edit->setValidator(Validator);
connect(edit, SIGNAL(returnPressed()), SLOT(slotApplyProperty()));
// hide, because it only replaces 'edit' in some cases
ComboEdit = new QComboBox(false, myParent);
ComboEdit = new QComboBox(false, v1);
ComboEdit->setShown(false);
gp2->addWidget(ComboEdit, 4,1);
connect(ComboEdit, SIGNAL(activated(const QString&)),
SLOT(slotApplyChange(const QString&)));
QHBox *h3 = new QHBox(myParent);
gp2->addWidget(h3, 5,1);
h3->setStretchFactor(new QWidget(h3),5); // stretchable placeholder
QHBox *h3 = new QHBox(v1);
EditButt = new QPushButton(tr("Edit"),h3);
EditButt->setEnabled(false);
EditButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
@ -293,17 +294,13 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d)
BrowseButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
connect(BrowseButt, SIGNAL(clicked()), SLOT(slotBrowseFile()));
disp = new QCheckBox(tr("display in schematic"), myParent);
gp2->addWidget(disp, 6,1);
disp = new QCheckBox(tr("display in schematic"), v1);
connect(disp, SIGNAL(stateChanged(int)), SLOT(slotApplyState(int)));
QVBoxLayout *v = new QVBoxLayout(); // stretchable placeholder
v->addStretch(2);
gp2->addLayout(v,7,1);
v1->setStretchFactor(new QWidget(v1),5); // stretchable placeholder
QHBox *h4 = new QHBox(myParent);
QHBox *h4 = new QHBox(v1);
h4->setSpacing(5);
gp2->addMultiCellWidget(h4, 8,8,1,1);
ButtAdd = new QPushButton(tr("Add"),h4);
ButtAdd->setEnabled(false);
ButtRem = new QPushButton(tr("Remove"),h4);
@ -324,9 +321,10 @@ ComponentDialog::ComponentDialog(Component *c, Schematic *d)
// ------------------------------------------------------------
CompNameEdit->setText(Comp->Name);
showName->setChecked(Comp->showName);
changed = false;
Comp->TextSize(tx_Dist, ty_Dist);
Comp->textSize(tx_Dist, ty_Dist);
int tmp = Comp->tx+tx_Dist - Comp->x1;
if((tmp > 0) || (tmp < -6)) tx_Dist = 0; // remember the text position
tmp = Comp->ty+ty_Dist - Comp->y1;
@ -568,6 +566,11 @@ void ComponentDialog::reject()
// Is called, if the "Apply"-button is pressed.
void ComponentDialog::slotApplyInput()
{
if(Comp->showName != showName->isChecked()) {
Comp->showName = showName->isChecked();
changed = true;
}
QString tmp;
Component *pc;
if(CompNameEdit->text().isEmpty()) CompNameEdit->setText(Comp->Name);
@ -739,7 +742,7 @@ void ComponentDialog::slotApplyInput()
if(changed) {
int dx, dy;
Comp->TextSize(dx, dy);
Comp->textSize(dx, dy);
if(tx_Dist != 0) {
Comp->tx += tx_Dist-dx;
tx_Dist = dx;
@ -782,7 +785,16 @@ void ComponentDialog::slotEditFile()
// properties.
void ComponentDialog::slotButtAdd()
{
QListViewItem *item = prop->selectedItem();
QListViewItem *item;
// Search if property with this name already exist.
for(item = prop->firstChild(); item != 0; item = item->itemBelow())
if(item->text(0) == NameEdit->text()) {
prop->setSelected(item, true);
slotSelectProperty(item);
return;
}
item = prop->selectedItem();
if(item == 0) item = prop->lastItem();
QString s = tr("no");

View File

@ -101,7 +101,7 @@ private:
QLineEdit *editParam, *editValues, *editStart, *editStop,
*editStep, *editNumber;
QCheckBox *checkSim, *checkParam, *checkValues, *checkStart, *checkStop,
*checkNumber, *checkType;
*checkNumber, *checkType, *showName;
QComboBox *editSim, *comboType;
};

View File

@ -113,5 +113,6 @@
#include "rs_flipflop.h"
#include "d_flipflop.h"
#include "jk_flipflop.h"
#include "vhdlfile.h"
#endif

View File

@ -86,16 +86,20 @@ void SpiceFile::recreate(Schematic *Doc)
Lines.append(new Line(-16, h, 16, h,QPen(QPen::darkBlue,2)));
Lines.append(new Line(-16, -h,-16, h,QPen(QPen::darkBlue,2)));
int i = fHeight/2;
int w, i = fHeight/2;
if(withSim) {
i = fHeight - 2;
Texts.append(new Text(-10, 0, QObject::tr("sim"), Qt::red));
tmp = QObject::tr("sim");
w = metrics.width(tmp);
Texts.append(new Text(w/-2, 0, tmp, Qt::red));
}
Texts.append(new Text(-15, -i, QObject::tr("spice")));
tmp = QObject::tr("spice");
w = metrics.width(tmp);
Texts.append(new Text(w/-2, -i, tmp));
i = 0;
int w, y = 15-h;
int y = 15-h;
while(i<No) {
Lines.append(new Line(-30, y,-16, y,QPen(QPen::darkBlue,2)));
Ports.append(new Port(-30, y));

View File

@ -73,13 +73,10 @@ void Subcircuit::recreate(Schematic *Doc)
}
int No;
QString FileName;
QFileInfo Info(Props.getFirst()->Value);
QString FileName(Props.getFirst()->Value);
QFileInfo Info(FileName);
if(Info.isRelative())
FileName = QucsWorkDir.filePath(Props.getFirst()->Value);
else
FileName = Props.getFirst()->Value;
FileName = QucsWorkDir.filePath(FileName);
tx = INT_MIN;
ty = INT_MIN;
@ -244,5 +241,6 @@ QString Subcircuit::VHDL_Code(int)
for(pp = Ports.next(); pp != 0; pp = Ports.next())
s += ", "+pp->Connection->Name; // node names
return s + ");";
s += ");";
return s;
}

View File

@ -0,0 +1,239 @@
/***************************************************************************
vhdlfile.cpp
--------------
begin : Sat Apr 15 2006
copyright : (C) 2006 by Michael Margraf
email : michael.margraf@alumni.tu-berlin.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "vhdlfile.h"
#include "qucs.h"
#include "main.h"
#include "schematic.h"
#include <qregexp.h>
VHDL_File::VHDL_File()
{
Type = isDigitalComponent;
Description = QObject::tr("VHDL file");
Props.append(new Property("File", "sub.vhdl", false,
QObject::tr("Name of VHDL file")));
createSymbol();
tx = x1+4;
ty = y2+4;
Model = "VHDL";
Name = "X";
}
VHDL_File::~VHDL_File()
{
}
Component* VHDL_File::newOne()
{
VHDL_File *p = new VHDL_File();
p->Props.getFirst()->Value = Props.getFirst()->Value;
p->recreate(0);
return p;
}
// -------------------------------------------------------
Element* VHDL_File::info(QString& Name, char* &BitmapFile, bool getNewOne)
{
Name = QObject::tr("VHDL file");
BitmapFile = "vhdlfile";
if(getNewOne) return new VHDL_File();
return 0;
}
// -------------------------------------------------------
QString VHDL_File::VHDL_Code(int)
{
QString s;
Port *pp = Ports.first();
if(pp) {
s = " " + Name + ": entity " + EntityName + " port map (";
// output all node names
if(pp) s += pp->Connection->Name;
for(pp = Ports.next(); pp != 0; pp = Ports.next())
s += ", "+pp->Connection->Name; // node names
s += ");";
}
return s;
}
// -------------------------------------------------------
// Returns a comma separated list of the port names of the last
// entity in this file.
QString VHDL_File::loadFile()
{
QString s, File(Props.getFirst()->Value);
QFileInfo Info(File);
if(Info.isRelative())
File = QucsWorkDir.filePath(File);
QFile f(File);
if(!f.open(IO_ReadOnly))
return QString("");
QTextStream stream(&f);
File = stream.read(); // QString is better for "find" function
f.close();
int i=0, j, k=0;
while((i=File.find("--", i)) >= 0) { // remove all VHDL comments
j = File.find('\n', i+2); // (This also finds "--" within a ...
if(j < 0) // string, but as no strings are ...
File = File.left(i); // allowed in entity headers, it ...
else // does not matter.)
File.remove(i, j-i);
i--;
}
QRegExp Expr;
Expr.setCaseSensitive(false);
for(;;) {
k--;
Expr.setPattern("\\bentity\\b"); // start of last entity
k = File.findRev(Expr, k);
if(k < 0)
return QString("");
Expr.setPattern("\\bend\\b"); // end of last entity
i = File.find(Expr, k+7);
if(i < 0)
return QString("");
s = File.mid(k+8, i-k-8); // cut out entity declaration
Expr.setPattern("\\b");
i = s.find(Expr);
if(i < 0)
return QString("");
j = s.find(Expr, i+1);
if(j < 0)
return QString("");
EntityName = s.mid(i, j-i); // save entity name
i = s.find(Expr, j+1);
if(i < 0)
return QString("");
j = s.find(Expr, i+1);
if(j < 0)
return QString("");
if(s.mid(i, j-i).lower() == "is") // really found start of entity ?
break;
if(k < 1) // already searched the whole text
return QString("");
}
Expr.setPattern("\\bport\\b"); // start of interface definition
i = s.find(Expr, j+1);
if(i < 0)
return QString("");
i = s.find('(', i+4) + 1;
if(i <= 0)
return QString("");
j = s.find(')', i);
if(j < 0)
return QString("");
s = s.mid(i, j-i);
s.remove(' ');
i = 0; // remove all VHDL identifiers (e.g. ": out bit;")
while((i=s.find(':', i)) >= 0) {
j = s.find(';', i+2);
if(j < 0)
s = s.left(i);
else
s.remove(i, j-i);
i--;
}
s.remove('\n');
s.remove('\t');
s.replace(';', ',');
return s;
}
// -------------------------------------------------------
void VHDL_File::createSymbol()
{
QFontMetrics metrics(QucsSettings.font); // get size of text
int fHeight = metrics.lineSpacing();
int No = 0;
QString tmp, PortNames = loadFile();
if(!PortNames.isEmpty())
No = PortNames.contains(',') + 1;
int h = 30*((No-1)/2) + 15;
Lines.append(new Line(-16, -h, 16, -h,QPen(QPen::darkBlue,2)));
Lines.append(new Line( 16, -h, 16, h,QPen(QPen::darkBlue,2)));
Lines.append(new Line(-16, h, 16, h,QPen(QPen::darkBlue,2)));
Lines.append(new Line(-16, -h,-16, h,QPen(QPen::darkBlue,2)));
tmp = QObject::tr("vhdl");
int w = metrics.width(tmp);
Texts.append(new Text(w/-2, fHeight/-2, tmp));
int y = 15-h, i = 0;
while(i<No) {
Lines.append(new Line(-30, y,-16, y,QPen(QPen::darkBlue,2)));
Ports.append(new Port(-30, y));
tmp = PortNames.section(',', i, i);
w = metrics.width(tmp);
Texts.append(new Text(-19-w, y-fHeight-2, tmp));
i++;
if(i == No) break;
Lines.append(new Line( 16, y, 30, y,QPen(QPen::darkBlue,2)));
Ports.append(new Port( 30, y));
tmp = PortNames.section(',', i, i);
Texts.append(new Text( 20, y-fHeight-2, tmp));
y += 60;
i++;
}
x1 = -30; y1 = -h-2;
x2 = 30; y2 = h+2;
}
// -------------------------------------------------------
void VHDL_File::recreate(Schematic *Doc)
{
if(Doc) {
Doc->Components->setAutoDelete(false);
Doc->deleteComp(this);
}
Ports.clear();
Lines.clear();
Texts.clear();
createSymbol();
performModification(); // rotate and mirror
if(Doc) {
Doc->insertRawComponent(this);
Doc->Components->setAutoDelete(true);
}
}

View File

@ -0,0 +1,40 @@
/***************************************************************************
vhdlfile.h
------------
begin : Sat Apr 15 2006
copyright : (C) 2006 by Michael Margraf
email : michael.margraf@alumni.tu-berlin.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef VHDLFILE_H
#define VHDLFILE_H
#include "component.h"
class VHDL_File : public Component {
public:
VHDL_File();
~VHDL_File();
Component* newOne();
static Element* info(QString&, char* &, bool getNewOne=false);
void recreate(Schematic*);
QString VHDL_Code(int);
private:
void createSymbol();
QString loadFile();
QString EntityName;
};
#endif

View File

@ -208,7 +208,7 @@ void ChangeDialog::slotButtReplace()
if(pp->Name != PropNameEdit->currentText()) continue;
int tx_Dist, ty_Dist, tmp;
pc->TextSize(tx_Dist, ty_Dist);
pc->textSize(tx_Dist, ty_Dist);
tmp = pc->tx+tx_Dist - pc->x1;
if((tmp > 0) || (tmp < -6)) tx_Dist = 0; // remember text position
tmp = pc->ty+ty_Dist - pc->y1;
@ -217,7 +217,7 @@ void ChangeDialog::slotButtReplace()
pp->Value = NewValueEdit->text();
int dx, dy;
pc->TextSize(dx, dy); // correct text position
pc->textSize(dx, dy); // correct text position
if(tx_Dist != 0) {
pc->tx += tx_Dist-dx;
tx_Dist = dx;

View File

@ -261,7 +261,12 @@ void SimMessage::startSimulator()
#endif
if(DocWidget->inherits("QTextEdit")) {
CommandLine << QucsSettings.BinDir + "qucsdigi" << DocName << DataSet
if(copyFile(DocName, QucsHomeDir.filePath("netlist.txt")) < 0) {
ErrText->insert(tr("ERROR: Cannot copy \"%1\" !").arg(DocName));
return;
}
CommandLine << QucsSettings.BinDir + QucsDigi << "netlist.txt" << DataSet
<< ((TextDoc*)DocWidget)->SimTime << QucsHomeDir.absPath()
<< QucsSettings.BinDir;
}
@ -432,3 +437,39 @@ void SimMessage::slotDisplayButton()
emit displayDataPage(DocName, DataDisplay);
accept();
}
// ------------------------------------------------------------------------
int SimMessage::copyFile(const QString& SrcName, const QString& DestName)
{
char *Buffer = (char*)malloc(0x10000);
if(!Buffer) return -10; // should never happen
QFile origFile, destFile;
origFile.setName(SrcName);
destFile.setName(DestName);
if(!origFile.open(IO_ReadOnly)) {
free(Buffer);
return -1;
}
if(!destFile.open(IO_WriteOnly)) {
origFile.close();
free(Buffer);
return -2;
}
int Num;
do { // copy data
Num = origFile.readBlock(Buffer, 0x10000);
if(Num < 0) break;
Num = destFile.writeBlock(Buffer, Num);
if(Num < 0) break;
} while(Num == 0x10000);
origFile.close();
destFile.close();
free(Buffer);
if(Num < 0) return -3;
return 0;
}

View File

@ -67,6 +67,7 @@ private:
void FinishSimulation(int);
void nextSPICE();
void startSimulator();
int copyFile(const QString&, const QString&);
public:
QWidget *DocWidget;

View File

@ -1169,9 +1169,9 @@ void MouseActions::MPressElement(Schematic *Doc, QMouseEvent *Event, int, int)
switch(Event->button()) {
case Qt::LeftButton :
// left mouse button inserts component into the schematic
Comp->TextSize(x1, y1);
Comp->textSize(x1, y1);
Doc->insertComponent(Comp);
Comp->TextSize(x2, y2);
Comp->textSize(x2, y2);
if(Comp->tx < Comp->x1) Comp->tx -= x2 - x1;
// enlarge viewarea if component lies outside the view

View File

@ -318,7 +318,7 @@ pInfoFunc digitalComps[] =
{&Digi_Source::info, &Logical_Inv::info, &Logical_OR::info,
&Logical_NOR::info, &Logical_AND::info, &Logical_NAND::info,
&Logical_XOR::info, &Logical_XNOR::info, &RS_FlipFlop::info,
&D_FlipFlop::info, &JK_FlipFlop::info, 0};
&D_FlipFlop::info, &JK_FlipFlop::info, &VHDL_File::info, 0};
pInfoFunc Simulations[] =
{&DC_Sim::info, &TR_Sim::info, &AC_Sim::info, &SP_Sim::info,
@ -404,7 +404,7 @@ void QucsApp::slotSelectComponent(QIconViewItem *item)
}
if(view->drawn)
((QScrollView*)DocumentTab->currentPage())->repaint(); // not update() !!!
((QScrollView*)DocumentTab->currentPage())->viewport()->update();
view->drawn = false;
// toggle last toolbar button off
@ -430,7 +430,8 @@ void QucsApp::slotSelectComponent(QIconViewItem *item)
char *Dummy2;
QString Dummy1;
if(Infos) view->selElem = (*Infos) (Dummy1, Dummy2, true);
if(Infos)
view->selElem = (*Infos) (Dummy1, Dummy2, true);
}
// ####################################################################
@ -1543,65 +1544,15 @@ void QucsApp::slotPopHierarchy()
void QucsApp::slotShowAll()
{
editText->setHidden(true); // disable text edit of component property
Schematic *Doc = (Schematic*)DocumentTab->currentPage();
int x1 = Doc->UsedX1;
int y1 = Doc->UsedY1;
int x2 = Doc->UsedX2;
int y2 = Doc->UsedY2;
if(x1 == INT_MAX) return;
if(y1 == INT_MAX) return;
if(x2 == INT_MIN) return;
if(y2 == INT_MIN) return;
x1 -= 40; y1 -= 40;
x2 += 40; y2 += 40;
float xScale = float(Doc->visibleWidth()) / float(x2-x1);
float yScale = float(Doc->visibleHeight()) / float(y2-y1);
if(xScale > yScale) xScale = yScale;
xScale /= Doc->Scale;
Doc->ViewX1 = x1;
Doc->ViewY1 = y1;
Doc->ViewX2 = x2;
Doc->ViewY2 = y2;
Doc->zoom(xScale);
getDoc()->showAll();
}
// -----------------------------------------------------------
// Sets the scale factor to 1.
void QucsApp::slotShowOne()
{
QWidget *w = DocumentTab->currentPage();
if(w->inherits("QTextEdit")) {
TextDoc *Doc = (TextDoc*)w;
Doc->Scale = (float)QucsSettings.font.pointSize();
Doc->zoomTo(QucsSettings.font.pointSize());
}
else {
editText->setHidden(true); // disable text edit of component property
Schematic *Doc = (Schematic*)w;
Doc->Scale = 1.0;
int x1 = Doc->UsedX1;
int y1 = Doc->UsedY1;
int x2 = Doc->UsedX2;
int y2 = Doc->UsedY2;
// view->Docs.current()->sizeOfAll(x1, y1, x2, y2);
if(x2==0) if(y2==0) if(x1==0) if(y1==0) x2 = y2 = 800;
Doc->ViewX1 = x1-40;
Doc->ViewY1 = y1-40;
Doc->ViewX2 = x2+40;
Doc->ViewY2 = y2+40;
Doc->resizeContents(x2-x1+80, y2-y1+80);
Doc->viewport()->update();
view->drawn = false;
}
editText->setHidden(true); // disable text edit of component property
getDoc()->showNoZoom();
}
// -----------------------------------------------------------
@ -1633,6 +1584,19 @@ void QucsApp::slotSimulate()
if(Doc->DocName.isEmpty()) // if document 'untitled' ...
if(!saveAs()) return; // ... save schematic before
// Perhaps the document was modified from another program ?
if(Doc->lastSaved.isValid()) {
QFileInfo Info(Doc->DocName);
if(Doc->lastSaved < 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 ?"),
tr("Reload"), tr("Keep it"));
if(No == 0)
Doc->load();
}
}
slotResetWarnings();
SimMessage *sim = new SimMessage(w, this);
// disconnect is automatically performed, if one of the involved objects
@ -1779,7 +1743,7 @@ void QucsApp::slotOpenContent(QListViewItem *item)
editText->setHidden(true); // disable text edit of component property
if(item == 0) return; // no item was double clicked
if(item->parent() == 0) return; // no component, but item "schematic", ...
if(item->parent() == 0) return; // no document, but item "schematic", ...
/*
QucsWorkDir.setPath(QucsHomeDir.path());
@ -1797,12 +1761,18 @@ void QucsApp::slotOpenContent(QListViewItem *item)
if((Suffix == "sch") || (Suffix == "dpl") || (Suffix == "vhdl")) {
gotoPage(Info.absFilePath());
if(item->text(1).isEmpty()) return; // is subcircuit ?
// switch on the 'select' action
select->blockSignals(true);
if(item->text(1).isEmpty()) // is subcircuit ?
if(Suffix != "vhdl") return; // is VHDL subcircuit ?
select->blockSignals(true); // switch on the 'select' action ...
select->setOn(true);
select->blockSignals(false);
slotSelect(true);
activeAction = select;
MouseMoveAction = 0;
MousePressAction = &MouseActions::MPressSelect;
MouseReleaseAction = &MouseActions::MReleaseSelect;
MouseDoubleClickAction = &MouseActions::MDoubleClickSelect;
return;
}
@ -1848,10 +1818,15 @@ void QucsApp::slotSelectSubcircuit(QListViewItem *item)
}
bool isVHDL = true;
if(item->parent() == 0) return;
if(item->parent()->text(0) != tr("Schematics"))
return; // return, if not clicked on schematic
if(item->text(1).isEmpty()) return; // return, if not a subcircuit
if(item->parent()->text(0) == tr("Schematics")) {
if(item->text(1).isEmpty())
return; // return, if not a subcircuit
isVHDL = false;
}
else if(item->parent()->text(0) != tr("VHDL"))
return;
// delete previously selected elements
if(view->selElem != 0) delete view->selElem;
@ -1865,7 +1840,11 @@ void QucsApp::slotSelectSubcircuit(QListViewItem *item)
}
activeAction = 0;
Component *Comp = new Subcircuit();
Component *Comp;
if(isVHDL)
Comp = new VHDL_File();
else
Comp = new Subcircuit();
Comp->Props.first()->Value = item->text(0);
Comp->recreate(0);
view->selElem = Comp;
@ -1904,7 +1883,6 @@ void QucsApp::switchSchematicDoc(bool SchematicMode)
onGrid->setEnabled(SchematicMode);
moveText->setEnabled(SchematicMode);
changeProps->setEnabled(SchematicMode);
magAll->setEnabled(SchematicMode);
editFind->setEnabled(!SchematicMode);
editFindAgain->setEnabled(!SchematicMode);
editRotate->setEnabled(SchematicMode);
@ -1912,14 +1890,14 @@ void QucsApp::switchSchematicDoc(bool SchematicMode)
editMirrorY->setEnabled(SchematicMode);
intoH->setEnabled(SchematicMode);
popH->setEnabled(SchematicMode);
insEquation->setEnabled(SchematicMode);
insGround->setEnabled(SchematicMode);
insPort->setEnabled(SchematicMode);
dcbias->setEnabled(SchematicMode);
insWire->setEnabled(SchematicMode);
insLabel->setEnabled(SchematicMode);
dcbias->setEnabled(SchematicMode);
insPort->setEnabled(SchematicMode);
insGround->setEnabled(SchematicMode);
insEquation->setEnabled(SchematicMode);
insEntity->setEnabled(!SchematicMode);
setMarker->setEnabled(SchematicMode);
showNet->setEnabled(SchematicMode);
}
// ---------------------------------------------------------

View File

@ -202,7 +202,7 @@ public slots:
void slotShowWarnings();
void slotResetWarnings();
void slotPrintCursorPosition(int, int);
void printCursorPosition(int, int);
private:
void initActions(); // initializes all QActions of the application
@ -237,7 +237,7 @@ public:
*helpIndex, *helpGetStart, *callEditor, *callFilter, *callLine,
*showMsg, *showNet, *alignTop, *alignBottom, *alignLeft, *alignRight,
*distrHor, *distrVert, *selectAll, *callLib, *callMatch, *changeProps,
*addToProj, *editFind, *editFindAgain;
*addToProj, *editFind, *editFindAgain, *insEntity;
public slots:
void slotEditRotate(bool); // rotate the selected items
@ -248,6 +248,7 @@ public slots:
void slotInsertEquation(bool);
void slotInsertGround(bool);
void slotInsertPort(bool);
void slotInsertEntity();
void slotSetWire(bool);
void slotSelect(bool);
void slotEditActivate(bool);

View File

@ -127,6 +127,7 @@ void QucsApp::slotEditActivate(bool on)
{
TextDoc *Doc = (TextDoc*)DocumentTab->currentPage();
if(Doc->inherits("QTextEdit")) {
Doc->clearParagraphBackground(Doc->tmpPosX);
Doc->outcommmentSelected();
editActivate->blockSignals(true);
@ -269,6 +270,16 @@ void QucsApp::slotEditPaste(bool on)
MouseDoubleClickAction = 0;
}
// -----------------------------------------------------------------------
void QucsApp::slotInsertEntity()
{
TextDoc *Doc = (TextDoc*)DocumentTab->currentPage();
Doc->viewport()->setFocus();
Doc->clearParagraphBackground(Doc->tmpPosX);
Doc->insert("entity is\n port ( : in bit);\nend;\n"
"architecture of is\n signal : bit;\nbegin\n\nend;\n\n");
}
// -----------------------------------------------------------------------
// Is called when the mouse is clicked upon the equation toolbar button.
void QucsApp::slotInsertEquation(bool on)
@ -728,7 +739,7 @@ void QucsApp::slotAddToProject()
Num = destFile.writeBlock(Buffer, Num);
if(Num < 0) {
QMessageBox::critical(this, tr("Error"), tr("Cannot write \"%1\" !").arg(*it));
continue;
break;
}
} while(Num == 0x10000);
@ -887,6 +898,7 @@ void QucsApp::slotCursorDown()
// -----------------------------------------------------------
// Is called if user clicked on component text of if return is
// pressed in the component text QLineEdit.
// In "view->MAx3" is the number of the current property.
void QucsApp::slotApplyCompText()
{
QString s;
@ -974,6 +986,7 @@ void QucsApp::slotApplyCompText()
if(pp->Description.find('[') >= 0) // is selection list ?
editText->setReadOnly(true);
Expr_CompProp.setPattern("[^\"=\\x5B\\x5D]+");
if(!pc->showName) n--;
}
else // it is the component name
Expr_CompProp.setPattern("[\\w_]+");

View File

@ -43,7 +43,7 @@ void QucsApp::initActions()
activeAction = 0; // no active action
fileNew = new QAction(tr("New"),
fileNew = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "filenew.png")),
tr("&New"), CTRL+Key_N, this);
fileNew->setStatusTip(tr("Creates a new document"));
@ -51,36 +51,35 @@ void QucsApp::initActions()
tr("New\n\nCreates a new schematic or data display document"));
connect(fileNew, SIGNAL(activated()), SLOT(slotFileNew()));
textNew = new QAction(tr("New Text"),
textNew = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "textnew.png")),
tr("New &Text"), CTRL+SHIFT+Key_M, this);
textNew->setStatusTip(tr("Creates a new text document"));
textNew->setWhatsThis(tr("New Text\n\nCreates a new text document"));
connect(textNew, SIGNAL(activated()), SLOT(slotTextNew()));
fileOpen = new QAction(tr("Open File"),
fileOpen = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "fileopen.png")),
tr("&Open..."), CTRL+Key_O, this);
fileOpen->setStatusTip(tr("Opens an existing document"));
fileOpen->setWhatsThis(tr("Open File\n\nOpens an existing document"));
connect(fileOpen, SIGNAL(activated()), SLOT(slotFileOpen()));
fileSave = new QAction(tr("Save File"),
fileSave = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "filesave.png")),
tr("&Save"), CTRL+Key_S, this);
fileSave->setStatusTip(tr("Saves the current document"));
fileSave->setWhatsThis(tr("Save File\n\nSaves the current document"));
connect(fileSave, SIGNAL(activated()), SLOT(slotFileSave()));
fileSaveAs = new QAction(tr("Save File As"), tr("Save as..."),
CTRL+Key_Minus, this);
fileSaveAs = new QAction(tr("Save as..."), CTRL+Key_Minus, this);
fileSaveAs->setStatusTip(
tr("Saves the current document under a new filename"));
fileSaveAs->setWhatsThis(
tr("Save As\n\nSaves the current document under a new filename"));
connect(fileSaveAs, SIGNAL(activated()), SLOT(slotFileSaveAs()));
fileSaveAll = new QAction(tr("Save All Files"),
fileSaveAll = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "filesaveall.png")),
tr("Save &All"), CTRL+Key_Plus, this);
fileSaveAll->setStatusTip(tr("Saves all open documents"));
@ -88,7 +87,7 @@ void QucsApp::initActions()
tr("Save All Files\n\nSaves all open documents"));
connect(fileSaveAll, SIGNAL(activated()), SLOT(slotFileSaveAll()));
fileClose = new QAction(tr("Close File"),
fileClose = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "fileclose.png")),
tr("&Close"), CTRL+Key_W, this);
fileClose->setStatusTip(tr("Closes the current document"));
@ -96,21 +95,19 @@ void QucsApp::initActions()
tr("Close File\n\nCloses the current document"));
connect(fileClose, SIGNAL(activated()), SLOT(slotFileClose()));
symEdit = new QAction(tr("&Edit Circuit Symbol"),
tr("Edit Circuit Symbol"), Key_F9, this);
symEdit = new QAction(tr("&Edit Circuit Symbol"), Key_F9, this);
symEdit->setStatusTip(tr("Edits the symbol for this schematic"));
symEdit->setWhatsThis(
tr("Edit Circuit Symbol\n\nEdits the symbol for this schematic"));
connect(symEdit, SIGNAL(activated()), SLOT(slotSymbolEdit()));
fileSettings = new QAction(tr("&Document Settings"),
tr("Document Settings..."), CTRL+Key_Period, this);
fileSettings->setStatusTip(tr("Document Settings"));
fileSettings = new QAction(
tr("&Document Settings..."), CTRL+Key_Period, this);
fileSettings->setWhatsThis(
tr("Settings\n\nSets properties of the file"));
connect(fileSettings, SIGNAL(activated()), SLOT(slotFileSettings()));
filePrint = new QAction(tr("Print File"),
filePrint = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "fileprint.png")),
tr("&Print..."), CTRL+Key_P, this);
filePrint->setStatusTip(tr("Prints the current document"));
@ -118,52 +115,48 @@ void QucsApp::initActions()
tr("Print File\n\nPrints the current document"));
connect(filePrint, SIGNAL(activated()), SLOT(slotFilePrint()));
filePrintSel = new QAction(tr("Print Selected Elements"),
tr("Print Selection..."), 0, this);
filePrintSel->setStatusTip(tr("Prints Selected Elements"));
filePrintSel = new QAction(tr("Print Selection..."), 0, this);
filePrintSel->setWhatsThis(
tr("Print Selected Elements\n\n"
"Prints selected elements of the current document"));
connect(filePrintSel, SIGNAL(activated()), SLOT(slotFilePrintSelected()));
fileQuit = new QAction(tr("Exit"), tr("E&xit"), CTRL+Key_Q, this);
fileQuit = new QAction(tr("E&xit"), CTRL+Key_Q, this);
fileQuit->setStatusTip(tr("Quits the application"));
fileQuit->setWhatsThis(tr("Exit\n\nQuits the application"));
connect(fileQuit, SIGNAL(activated()), SLOT(slotFileQuit()));
applSettings = new QAction(tr("Application Settings"),
applSettings = new QAction(
tr("Application Settings..."), CTRL+Key_Comma, this);
applSettings->setStatusTip(tr("Application Settings"));
applSettings->setWhatsThis(
tr("Qucs Settings\n\nSets properties of the application"));
connect(applSettings, SIGNAL(activated()), SLOT(slotApplSettings()));
alignTop = new QAction(tr("Align top"), tr("Align top"), CTRL+Key_T, this);
alignTop = new QAction(tr("Align top"), CTRL+Key_T, this);
alignTop->setStatusTip(tr("Align top selected elements"));
alignTop->setWhatsThis(
tr("Align top\n\nAlign selected elements to their upper edge"));
connect(alignTop, SIGNAL(activated()), SLOT(slotAlignTop()));
alignBottom = new QAction(tr("Align bottom"), tr("Align bottom"), 0, this);
alignBottom = new QAction(tr("Align bottom"), 0, this);
alignBottom->setStatusTip(tr("Align bottom selected elements"));
alignBottom->setWhatsThis(
tr("Align bottom\n\nAlign selected elements to their lower edge"));
connect(alignBottom, SIGNAL(activated()), SLOT(slotAlignBottom()));
alignLeft = new QAction(tr("Align left"), tr("Align left"), 0, this);
alignLeft = new QAction(tr("Align left"), 0, this);
alignLeft->setStatusTip(tr("Align left selected elements"));
alignLeft->setWhatsThis(
tr("Align left\n\nAlign selected elements to their left edge"));
connect(alignLeft, SIGNAL(activated()), SLOT(slotAlignLeft()));
alignRight = new QAction(tr("Align right"), tr("Align right"), 0, this);
alignRight = new QAction(tr("Align right"), 0, this);
alignRight->setStatusTip(tr("Align right selected elements"));
alignRight->setWhatsThis(
tr("Align right\n\nAlign selected elements to their right edge"));
connect(alignRight, SIGNAL(activated()), SLOT(slotAlignRight()));
distrHor = new QAction(tr("Distribute horizontally"),
tr("Distribute horizontally"), 0, this);
distrHor = new QAction(tr("Distribute horizontally"), 0, this);
distrHor->setStatusTip(tr("Distribute equally horizontally"));
distrHor->setWhatsThis(
tr("Distribute horizontally\n\n"
@ -178,48 +171,42 @@ void QucsApp::initActions()
"Distribute vertically selected elements"));
connect(distrVert, SIGNAL(activated()), SLOT(slotDistribVert()));
onGrid = new QAction(tr("Set on Grid"), tr("Set on Grid"),
CTRL+Key_U, this);
onGrid->setStatusTip(tr("Set on Grid"));
onGrid = new QAction(tr("Set on Grid"), CTRL+Key_U, this);
onGrid->setWhatsThis(
tr("Set on Grid\n\nSets selected elements on grid"));
onGrid->setToggleAction(true);
connect(onGrid, SIGNAL(toggled(bool)), SLOT(slotOnGrid(bool)));
moveText = new QAction(tr("Move Component Text"),
tr("Move Component Text"), CTRL+Key_K, this);
moveText->setStatusTip(tr("Move Component Text"));
moveText = new QAction(tr("Move Component Text"), CTRL+Key_K, this);
moveText->setWhatsThis(
tr("Move Component Text\n\nMoves the property text of components"));
moveText->setToggleAction(true);
connect(moveText, SIGNAL(toggled(bool)), SLOT(slotMoveText(bool)));
changeProps = new QAction(tr("Change Property Values..."),
tr("Change Property Values..."), Key_F7, this);
changeProps->setStatusTip(tr("Change Property Values"));
changeProps = new QAction(tr("Change Property Values..."), Key_F7, this);
changeProps->setWhatsThis(
tr("Change Property Values\n\nChange Property Value of Components"));
connect(changeProps, SIGNAL(activated()), SLOT(slotChangeProps()));
editCut = new QAction(tr("Cut"),
editCut = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "editcut.png")),
tr("Cu&t"), CTRL+Key_X, this);
editCut->setStatusTip(
tr("Cuts the selected section and puts it to the clipboard"));
tr("Cuts out the selection and puts it into the clipboard"));
editCut->setWhatsThis(
tr("Cut\n\nCuts the selected section and puts it to the clipboard"));
tr("Cut\n\nCuts out the selection and puts it into the clipboard"));
connect(editCut, SIGNAL(activated()), SLOT(slotEditCut()));
editCopy = new QAction(tr("Copy"),
editCopy = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "editcopy.png")),
tr("&Copy"), CTRL+Key_C, this);
editCopy->setStatusTip(
tr("Copies the selected section to the clipboard"));
tr("Copies the selection into the clipboard"));
editCopy->setWhatsThis(
tr("Copy\n\nCopies the selected section to the clipboard"));
tr("Copy\n\nCopies the selection into the clipboard"));
connect(editCopy, SIGNAL(activated()), SLOT(slotEditCopy()));
editPaste = new QAction(tr("Paste"),
editPaste = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "editpaste.png")),
tr("&Paste"), CTRL+Key_V, this);
editPaste->setStatusTip(
@ -229,7 +216,7 @@ void QucsApp::initActions()
editPaste->setToggleAction(true);
connect(editPaste, SIGNAL(toggled(bool)), SLOT(slotEditPaste(bool)));
editDelete = new QAction(tr("Delete"),
editDelete = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "editdelete.png")),
tr("&Delete"), Key_Delete, this);
editDelete->setStatusTip(tr("Deletes the selected components"));
@ -238,12 +225,12 @@ void QucsApp::initActions()
editDelete->setToggleAction(true);
connect(editDelete, SIGNAL(toggled(bool)), SLOT(slotEditDelete(bool)));
editFind = new QAction(tr("Find"), tr("Find..."), CTRL+Key_F, this);
editFind = new QAction(tr("Find..."), CTRL+Key_F, this);
editFind->setStatusTip(tr("Find a piece of text"));
editFind->setWhatsThis(tr("Find\n\nSearches for a piece of text"));
connect(editFind, SIGNAL(activated()), SLOT(slotEditFind()));
editFindAgain = new QAction(tr("Find Again"), tr("Find Again"), Key_F3, this);
editFindAgain = new QAction(tr("Find Again"), Key_F3, this);
editFindAgain->setStatusTip(tr("Find same text again"));
editFindAgain->setWhatsThis(
tr("Find\n\nSearches for the same piece of text again"));
@ -265,62 +252,56 @@ void QucsApp::initActions()
mainAccel->connectItem(mainAccel->insertItem(Key_Tab),
this, SLOT(slotNextTab()));
undo = new QAction(tr("Undo"),
undo = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "undo.png")),
tr("&Undo"), CTRL+Key_Z, this);
undo->setStatusTip(tr("Undoes the last command"));
undo->setWhatsThis(tr("Undo\n\nMakes the last action undone"));
connect(undo, SIGNAL(activated()), SLOT(slotEditUndo()));
redo = new QAction(tr("Redo"),
redo = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "redo.png")),
tr("&Redo"), CTRL+Key_Y, this);
redo->setStatusTip(tr("Redoes the last command"));
redo->setWhatsThis(tr("Redo\n\nRepeats the last action once more"));
connect(redo, SIGNAL(activated()), SLOT(slotEditRedo()));
projNew = new QAction(tr("New Project"), tr("&New Project..."),
CTRL+SHIFT+Key_N, this);
projNew = new QAction(tr("&New Project..."), CTRL+SHIFT+Key_N, this);
projNew->setStatusTip(tr("Creates a new project"));
projNew->setWhatsThis(tr("New Project\n\nCreates a new project"));
connect(projNew, SIGNAL(activated()), SLOT(slotProjNewButt()));
projOpen = new QAction(tr("Open Project"), tr("&Open Project..."),
projOpen = new QAction(tr("&Open Project..."),
CTRL+SHIFT+Key_O, this);
projOpen->setStatusTip(tr("Opens a project"));
projOpen->setWhatsThis(
tr("Open Project\n\nOpens an existing project"));
connect(projOpen, SIGNAL(activated()), SLOT(slotMenuOpenProject()));
projDel = new QAction(tr("Delete Project"), tr("&Delete Project..."),
CTRL+SHIFT+Key_D, this);
projDel->setStatusTip(tr("Deletes a project"));
projDel = new QAction(tr("&Delete Project..."), CTRL+SHIFT+Key_D, this);
projDel->setWhatsThis(
tr("Delete Project\n\nDeletes an existing project"));
connect(projDel, SIGNAL(activated()), SLOT(slotMenuDelProject()));
projClose = new QAction(tr("Close Project"), tr("&Close Project"),
CTRL+SHIFT+Key_W, this);
projClose->setStatusTip(tr("Close current project"));
projClose = new QAction(tr("&Close Project"), CTRL+SHIFT+Key_W, this);
projClose->setWhatsThis(
tr("Close Project\n\nCloses the current project"));
connect(projClose, SIGNAL(activated()), SLOT(slotMenuCloseProject()));
addToProj = new QAction(tr("Add Files to Project"), tr("&Add Files to Project..."),
addToProj = new QAction(tr("&Add Files to Project..."),
CTRL+SHIFT+Key_A, this);
addToProj->setStatusTip(tr("Copies files to project directory"));
addToProj->setWhatsThis(
tr("Add Files to Project\n\nCopies files to project directory"));
connect(addToProj, SIGNAL(activated()), SLOT(slotAddToProject()));
magAll = new QAction(tr("View All"),
magAll = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "viewmagfit.png")),
tr("View All"), Key_0, this);
magAll->setStatusTip(tr("Views the whole page"));
magAll->setStatusTip(tr("Show the whole page"));
magAll->setWhatsThis(tr("View All\n\nShows the whole page content"));
connect(magAll, SIGNAL(activated()), SLOT(slotShowAll()));
magOne = new QAction(tr("View 1:1"),
magOne = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "viewmag1.png")),
tr("View 1:1"), Key_1, this);
magOne->setStatusTip(tr("Views without magnification"));
@ -328,7 +309,7 @@ void QucsApp::initActions()
tr("View 1:1\n\nShows the page content without magnification"));
connect(magOne, SIGNAL(activated()), SLOT(slotShowOne()));
magPlus = new QAction(tr("Zoom in"),
magPlus = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "viewmag+.png")),
tr("Zoom in"), Key_Plus, this);
magPlus->setStatusTip(tr("Zooms into the current view"));
@ -336,29 +317,28 @@ void QucsApp::initActions()
magPlus->setToggleAction(true);
connect(magPlus, SIGNAL(toggled(bool)), SLOT(slotZoomIn(bool)));
magMinus = new QAction(tr("Zoom out"),
magMinus = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "viewmag-.png")),
tr("Zoom out"), Key_Minus, this);
magMinus->setStatusTip(tr("Zooms out the current view"));
magMinus->setWhatsThis(tr("Zoom out\n\nZooms out the current view"));
connect(magMinus, SIGNAL(activated()), SLOT(slotZoomOut()));
select = new QAction(tr("Select"),
select = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "pointer.png")),
tr("Select"), Key_Escape, this);
select->setStatusTip(tr("Select mode"));
select->setWhatsThis(tr("Select\n\nSelect mode"));
select->setStatusTip(tr("Activate select mode"));
select->setWhatsThis(tr("Select\n\nActivates select mode"));
select->setToggleAction(true);
connect(select, SIGNAL(toggled(bool)), SLOT(slotSelect(bool)));
selectAll = new QAction(tr("Select All"), tr("Select All"),
CTRL+Key_A, this);
selectAll = new QAction(tr("Select All"), CTRL+Key_A, this);
selectAll->setStatusTip(tr("Selects all elements"));
selectAll->setWhatsThis(
tr("Select All\n\nSelects all elements of the document"));
connect(selectAll, SIGNAL(activated()), SLOT(slotSelectAll()));
editRotate = new QAction(tr("Rotate"),
editRotate = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "rotate_ccw.png")),
tr("Rotate"), CTRL+Key_R, this);
editRotate->setStatusTip(tr("Rotates the selected component by 90°"));
@ -367,34 +347,30 @@ void QucsApp::initActions()
editRotate->setToggleAction(true);
connect(editRotate, SIGNAL(toggled(bool)), SLOT(slotEditRotate(bool)));
editMirror = new QAction(tr("Mirror about X Axis"),
editMirror = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "mirror.png")),
tr("Mirror about X Axis"), CTRL+Key_J, this);
editMirror->setStatusTip(tr("Mirrors the selected item about X axis"));
editMirror->setWhatsThis(
tr("Mirror about X Axis\n\nMirrors the selected item about X Axis"));
editMirror->setToggleAction(true);
connect(editMirror, SIGNAL(toggled(bool)), SLOT(slotEditMirrorX(bool)));
editMirrorY = new QAction(tr("Mirror about Y Axis"),
editMirrorY = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "mirrory.png")),
tr("Mirror about Y Axis"), CTRL+Key_M, this);
editMirrorY->setStatusTip(tr("Mirrors the selected item about Y axis"));
editMirrorY->setWhatsThis(
tr("Mirror about Y Axis\n\nMirrors the selected item about Y Axis"));
editMirrorY->setToggleAction(true);
connect(editMirrorY, SIGNAL(toggled(bool)), SLOT(slotEditMirrorY(bool)));
intoH = new QAction(tr("Go into Subcircuit"),
intoH = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "bottom.png")),
tr("Go into Subcircuit"), CTRL+Key_I, this);
intoH->setStatusTip(tr("Goes inside subcircuit"));
intoH->setWhatsThis(
tr("Go into Subcircuit\n\nGoes inside the selected subcircuit"));
connect(intoH, SIGNAL(activated()), SLOT(slotIntoHierarchy()));
// intoH->setEnabled(false);
popH = new QAction(tr("Pop out"),
popH = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "top.png")),
tr("Pop out"), CTRL+Key_H, this);
popH->setStatusTip(tr("Pop outside subcircuit"));
@ -403,7 +379,7 @@ void QucsApp::initActions()
connect(popH, SIGNAL(activated()), SLOT(slotPopHierarchy()));
popH->setEnabled(false); // only enabled if useful !!!!
editActivate = new QAction(tr("Deactivate/Activate"),
editActivate = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "deactiv.png")),
tr("Deactivate/Activate"), CTRL+Key_D, this);
editActivate->setStatusTip(
@ -413,41 +389,37 @@ void QucsApp::initActions()
editActivate->setToggleAction(true);
connect(editActivate, SIGNAL(toggled(bool)), SLOT(slotEditActivate(bool)));
insEquation = new QAction(tr("Insert Equation"),
insEquation = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "equation.png")),
tr("Insert Equation"), 0, this);
insEquation->setStatusTip(tr("Inserts equation"));
tr("Insert Equation"), CTRL+Key_Less, this);
insEquation->setWhatsThis(
tr("Insert Equation\n\nInserts a user defined equation"));
insEquation->setToggleAction(true);
connect(insEquation, SIGNAL(toggled(bool)), SLOT(slotInsertEquation(bool)));
insGround = new QAction(tr("Insert Ground"),
insGround = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "ground.png")),
tr("Insert Ground"), CTRL+Key_G, this);
insGround->setStatusTip(tr("Inserts ground"));
insGround->setWhatsThis(
tr("Insert Ground\n\nInserts a ground symbol"));
insGround->setToggleAction(true);
connect(insGround, SIGNAL(toggled(bool)), SLOT(slotInsertGround(bool)));
insPort = new QAction(tr("Insert Port"),
insPort = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "port.png")),
tr("Insert Port"), 0, this);
insPort->setStatusTip(tr("Inserts port"));
insPort->setWhatsThis(tr("Insert Port\n\nInserts a port symbol"));
insPort->setToggleAction(true);
connect(insPort, SIGNAL(toggled(bool)), SLOT(slotInsertPort(bool)));
insWire = new QAction(tr("Insert Wire"),
insWire = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "wire.png")),
tr("Wire"), CTRL+Key_E, this);
insWire->setStatusTip(tr("Inserts a wire"));
insWire->setWhatsThis(tr("Wire\n\nInserts a wire"));
insWire->setToggleAction(true);
connect(insWire, SIGNAL(toggled(bool)), SLOT(slotSetWire(bool)));
insLabel = new QAction(tr("Insert Wire/Pin Label"),
insLabel = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "nodename.png")),
tr("Wire Label"), CTRL+Key_L, this);
insLabel->setStatusTip(tr("Inserts a wire or pin label"));
@ -456,42 +428,43 @@ void QucsApp::initActions()
insLabel->setToggleAction(true);
connect(insLabel, SIGNAL(toggled(bool)), SLOT(slotInsertLabel(bool)));
callEditor = new QAction(tr("Text editor"), tr("Text Editor"),
CTRL+Key_1, this);
insEntity = new QAction(tr("VHDL entity"), CTRL+Key_Space, this);
insEntity->setStatusTip(tr("Inserts sceleton of VHDL entity"));
insEntity->setWhatsThis(
tr("VHDL entity\n\nInserts the sceleton of a VHDL entity"));
connect(insEntity, SIGNAL(activated()), SLOT(slotInsertEntity()));
callEditor = new QAction(tr("Text Editor"), CTRL+Key_1, this);
callEditor->setStatusTip(tr("Starts the Qucs text editor"));
callEditor->setWhatsThis(
tr("Text editor\n\nStarts the Qucs text editor"));
connect(callEditor, SIGNAL(activated()), SLOT(slotCallEditor()));
callFilter = new QAction(tr("Filter synthesis"), tr("Filter synthesis"),
CTRL+Key_2, this);
callFilter = new QAction(tr("Filter synthesis"), CTRL+Key_2, this);
callFilter->setStatusTip(tr("Starts QucsFilter"));
callFilter->setWhatsThis(
tr("Filter synthesis\n\nStarts QucsFilter"));
connect(callFilter, SIGNAL(activated()), SLOT(slotCallFilter()));
callLine = new QAction(tr("Line calculation"), tr("Line calculation"),
CTRL+Key_3, this);
callLine = new QAction(tr("Line calculation"), CTRL+Key_3, this);
callLine->setStatusTip(tr("Starts QucsTrans"));
callLine->setWhatsThis(
tr("Line calculation\n\nStarts transmission line calculator"));
connect(callLine, SIGNAL(activated()), SLOT(slotCallLine()));
callLib = new QAction(tr("Component Library"), tr("Component Library"),
CTRL+Key_4, this);
callLib = new QAction(tr("Component Library"), CTRL+Key_4, this);
callLib->setStatusTip(tr("Starts QucsLib"));
callLib->setWhatsThis(
tr("Component Library\n\nStarts component library program"));
connect(callLib, SIGNAL(activated()), SLOT(slotCallLibrary()));
callMatch = new QAction(tr("Matching Circuit"), tr("Matching Circuit"),
CTRL+Key_5, this);
callMatch = new QAction(tr("Matching Circuit"), CTRL+Key_5, this);
callMatch->setStatusTip(tr("Creates Matching Circuit"));
callMatch->setWhatsThis(
tr("Matching Circuit\n\nDialog for Creating Matching Circuit"));
connect(callMatch, SIGNAL(activated()), SLOT(slotCallMatch()));
simulate = new QAction(tr("Simulate"),
simulate = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "gear.png")),
tr("Simulate"), Key_F2, this);
simulate->setStatusTip(tr("Simulates the current schematic"));
@ -499,7 +472,7 @@ void QucsApp::initActions()
tr("Simulate\n\nSimulates the current schematic"));
connect(simulate, SIGNAL(activated()), SLOT(slotSimulate()));
dpl_sch = new QAction(tr("View Data Display/Schematic"),
dpl_sch = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "rebuild.png")),
tr("View Data Display/Schematic"), Key_F4, this);
dpl_sch->setStatusTip(tr("Changes to data display or schematic page"));
@ -508,14 +481,13 @@ void QucsApp::initActions()
tr("Changes to data display or schematic page"));
connect(dpl_sch, SIGNAL(activated()), SLOT(slotToPage()));
dcbias = new QAction(tr("Calculate DC bias"), tr("Calculate DC bias"),
Key_F8, this);
dcbias = new QAction(tr("Calculate DC bias"), Key_F8, this);
dcbias->setStatusTip(tr("Calculates DC bias and shows it"));
dcbias->setWhatsThis(
tr("Calculate DC bias\n\nCalculates DC bias and shows it"));
connect(dcbias, SIGNAL(activated()), SLOT(slotDCbias()));
setMarker = new QAction(tr("Set Marker"),
setMarker = new QAction(
QIconSet(QImage(QucsSettings.BitmapDir + "marker.png")),
tr("Set Marker on Graph"), CTRL+Key_B, this);
setMarker->setStatusTip(tr("Sets a marker on a diagram's graph"));
@ -524,54 +496,49 @@ void QucsApp::initActions()
setMarker->setToggleAction(true);
connect(setMarker, SIGNAL(toggled(bool)), SLOT(slotSetMarker(bool)));
showMsg = new QAction(tr("Show Last Messages"),
tr("Show Last Messages"), Key_F5, this);
showMsg = new QAction(tr("Show Last Messages"), Key_F5, this);
showMsg->setStatusTip(tr("Shows last simulation messages"));
showMsg->setWhatsThis(
tr("Show Last Messages\n\nShows the messages of the last simulation"));
connect(showMsg, SIGNAL(activated()), SLOT(slotShowLastMsg()));
showNet = new QAction(tr("Show Last Netlist"), tr("Show Last Netlist"),
Key_F6, this);
showNet = new QAction(tr("Show Last Netlist"), Key_F6, this);
showNet->setStatusTip(tr("Shows last simulation netlist"));
showNet->setWhatsThis(
tr("Show Last Netlist\n\nShows the netlist of the last simulation"));
connect(showNet, SIGNAL(activated()), SLOT(slotShowLastNetlist()));
viewToolBar = new QAction(tr("Toolbar"), tr("Tool&bar"), 0, this, 0, true);
viewToolBar = new QAction(tr("Tool&bar"), 0, this);
viewToolBar->setToggleAction(true);
viewToolBar->setStatusTip(tr("Enables/disables the toolbar"));
viewToolBar->setWhatsThis(tr("Toolbar\n\nEnables/disables the toolbar"));
connect(viewToolBar, SIGNAL(toggled(bool)),
this, SLOT(slotViewToolBar(bool)));
viewStatusBar = new QAction(tr("Statusbar"), tr("&Statusbar"),
0, this, 0, true);
viewStatusBar = new QAction(tr("&Statusbar"), 0, this);
viewStatusBar->setToggleAction(true);
viewStatusBar->setStatusTip(tr("Enables/disables the statusbar"));
viewStatusBar->setWhatsThis(
tr("Statusbar\n\nEnables/disables the statusbar"));
connect(viewStatusBar, SIGNAL(toggled(bool)),
this, SLOT(slotViewStatusBar(bool)));
helpIndex = new QAction(tr("Help Index"), tr("Help Index..."),
Key_F1, this);
helpIndex = new QAction(tr("Help Index..."), Key_F1, this);
helpIndex->setStatusTip(tr("Index of Qucs Help"));
helpIndex->setWhatsThis(tr("Help Index\n\nIndex of intern Qucs help"));
connect(helpIndex, SIGNAL(activated()), SLOT(slotHelpIndex()));
helpGetStart = new QAction(tr("Getting Started"),
tr("Getting Started..."), 0, this);
helpGetStart = new QAction(tr("Getting Started..."), 0, this);
helpGetStart->setStatusTip(tr("Getting Started with Qucs"));
helpGetStart->setWhatsThis(
tr("Getting Started\n\nShort introduction into Qucs"));
connect(helpGetStart, SIGNAL(activated()), SLOT(slotGettingStarted()));
helpAboutApp = new QAction(tr("About"), tr("&About Qucs..."), 0, this);
helpAboutApp->setStatusTip(tr("About the application"));
helpAboutApp = new QAction(tr("&About Qucs..."), 0, this);
helpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
connect(helpAboutApp, SIGNAL(activated()), SLOT(slotHelpAbout()));
helpAboutQt = new QAction(tr("About Qt"), tr("About Qt..."), 0, this);
helpAboutQt->setStatusTip(tr("About Qt"));
helpAboutQt = new QAction(tr("About Qt..."), 0, this);
helpAboutQt->setWhatsThis(tr("About Qt\n\nAbout Qt by Trolltech"));
connect(helpAboutQt, SIGNAL(activated()), SLOT(slotHelpAboutQt()));
}
@ -639,6 +606,7 @@ void QucsApp::initMenuBar()
insGround->addTo(insMenu);
insPort->addTo(insMenu);
setMarker->addTo(insMenu);
insEntity->addTo(insMenu);
projMenu = new QPopupMenu(); // menuBar entry projMenu
projNew->addTo(projMenu);
@ -718,12 +686,12 @@ void QucsApp::initToolBar()
workToolbar = new QToolBar(this);
select->addTo(workToolbar);
editActivate->addTo(workToolbar);
editMirror->addTo(workToolbar);
editMirrorY->addTo(workToolbar);
editRotate->addTo(workToolbar);
intoH->addTo(workToolbar);
popH->addTo(workToolbar);
editActivate->addTo(workToolbar);
insWire->addTo(workToolbar);
insLabel->addTo(workToolbar);
insEquation->addTo(workToolbar);
@ -786,7 +754,7 @@ void QucsApp::slotResetWarnings()
}
// ----------------------------------------------------------
void QucsApp::slotPrintCursorPosition(int x, int y)
void QucsApp::printCursorPosition(int x, int y)
{
PositionLabel->setText(QString::number(x)+" : "+QString::number(y));
PositionLabel->setMinimumWidth(PositionLabel->width());

View File

@ -19,6 +19,7 @@
#define QUCSDOC_H
#include <qstring.h>
#include <qdatetime.h>
class QucsApp;
class QPrinter;
@ -32,17 +33,20 @@ public:
QucsDoc(QucsApp*, const QString&);
virtual ~QucsDoc() {};
virtual void setName(const QString&) {};
virtual bool load() { return true; };
virtual int save() { return 0; };
virtual void print(QPrinter*, bool) {};
virtual void becomeCurrent(bool) {};
virtual void setName(const QString&) {};
virtual bool load() { return true; };
virtual int save() { return 0; };
virtual void print(QPrinter*, bool) {};
virtual void becomeCurrent(bool) {};
virtual float zoom(float) { return 1.0; };
virtual void showAll() {};
virtual void showNoZoom() {};
QString DocName;
QString DataSet; // name of the default dataset
QString DataDisplay; // name of the default data display
QString SimTime; // used for VHDL simulation, but stored in datadisplay
QDateTime lastSaved;
float Scale;
QucsApp *App;
@ -50,6 +54,7 @@ public:
bool SimOpenDpl; // open data display after simulation ?
int showBias; // -1=no, 0=calculation running, >0=show DC bias points
bool GridOn;
int tmpPosX, tmpPosY;
};
#endif

View File

@ -130,7 +130,7 @@ Schematic::~Schematic()
void Schematic::becomeCurrent(bool update)
{
QString *ps;
App->slotPrintCursorPosition(0, 0);
App->printCursorPosition(0, 0);
if(symbolMode) {
Nodes = &SymbolNodes;
@ -474,6 +474,55 @@ float Schematic::zoom(float s)
return Scale;
}
// ---------------------------------------------------
void Schematic::showAll()
{
int x1 = UsedX1;
int y1 = UsedY1;
int x2 = UsedX2;
int y2 = UsedY2;
if(x1 == INT_MAX) return;
if(y1 == INT_MAX) return;
if(x2 == INT_MIN) return;
if(y2 == INT_MIN) return;
x1 -= 40; y1 -= 40;
x2 += 40; y2 += 40;
float xScale = float(visibleWidth()) / float(x2-x1);
float yScale = float(visibleHeight()) / float(y2-y1);
if(xScale > yScale) xScale = yScale;
xScale /= Scale;
ViewX1 = x1;
ViewY1 = y1;
ViewX2 = x2;
ViewY2 = y2;
zoom(xScale);
}
// ---------------------------------------------------
void Schematic::showNoZoom()
{
Scale = 1.0;
int x1 = UsedX1;
int y1 = UsedY1;
int x2 = UsedX2;
int y2 = UsedY2;
// sizeOfAll(x1, y1, x2, y2);
if(x2==0) if(y2==0) if(x1==0) if(y1==0) x2 = y2 = 800;
ViewX1 = x1-40;
ViewY1 = y1-40;
ViewX2 = x2+40;
ViewY2 = y2+40;
resizeContents(x2-x1+80, y2-y1+80);
viewport()->update();
App->view->drawn = false;
}
// -----------------------------------------------------------
// Enlarge the viewport area if the coordinates x1-x2/y1-y2 exceed the
// visible area.
@ -922,7 +971,15 @@ bool Schematic::paste(QTextStream *stream, QPtrList<Element> *pe)
// Loads this Qucs document.
bool Schematic::load()
{
DocComps.clear();
DocWires.clear();
DocNodes.clear();
DocDiags.clear();
DocPaints.clear();
SymbolPaints.clear();
if(!loadDocument()) return false;
lastSaved = QDateTime::currentDateTime();
UndoStack.clear();
setChanged(false, true); // "not changed" state, but put on undo stack
UndoStack.current()->at(1) = 'i'; // state of being unchanged
@ -945,6 +1002,7 @@ int Schematic::save()
{
int result = adjustPortNumbers();// same port number for schematic and symbol
saveDocument();
lastSaved = QDateTime::currentDateTime();
if(result >= 0) {
setChanged(false);
QString *p, *ps = UndoStack.current();

View File

@ -54,6 +54,8 @@ public:
bool elementsOnGrid();
float zoom(float);
void showAll();
void showNoZoom();
void enlargeView(int, int, int, int);
void switchPaintMode();
int adjustPortNumbers();
@ -90,8 +92,7 @@ public:
// Two of those data sets are needed for Schematic and for symbol.
// Which one is in "tmp..." depends on "symbolMode".
float tmpScale;
int tmpPosX, tmpPosY;
float tmpScale;
int tmpViewX1, tmpViewY1, tmpViewX2, tmpViewY2;
int tmpUsedX1, tmpUsedY1, tmpUsedX2, tmpUsedY2;

View File

@ -1849,9 +1849,18 @@ void Schematic::recreateComponent(Component *Comp)
int x = Comp->tx, y = Comp->ty;
int x1 = Comp->x1, x2 = Comp->x2, y1 = Comp->y1, y2 = Comp->y2;
QString tmp = Comp->Name; // is sometimes changed by "recreate"
Comp->recreate(this); // to apply changes to the schematic symbol
Comp->Name = tmp;
if(x < x1)
x += Comp->x1 - x1;
else if(x > x2)
x += Comp->x2 - x2;
if(y < y1)
y += Comp->y1 - y1;
else if(y > y2)
y += Comp->y2 - y2;
Comp->tx = x; Comp->ty = y;
@ -2014,7 +2023,7 @@ Component* Schematic::selectCompText(int x_, int y_, int& w, int& h)
b = pc->cy + pc->ty;
if(y_ < b) continue;
pc->TextSize(dx, dy);
pc->textSize(dx, dy);
if(x_ > a+dx) continue;
if(y_ > b+dy) continue;

View File

@ -664,7 +664,7 @@ QString Schematic::createSymbolUndoString(char Op)
}
// -------------------------------------------------------------
// Is quite similiar to "load()" but with less error checking.
// Is quite similiar to "loadDocument()" but with less error checking.
// Used for "undo" function.
bool Schematic::rebuild(QString *s)
{
@ -866,6 +866,34 @@ bool Schematic::giveNodeNames(QTextStream *stream, int& countInit,
else s = "SPICEo\""+s;
Collect.append(s);
}
else if(pc->Model == "VHDL") {
s = pc->Props.getFirst()->Value;
if(s.isEmpty()) {
ErrText->insert(QObject::tr("ERROR: No file name in VHDL component \"%1\".").
arg(pc->Name));
return false;
}
if(StringList.findIndex(s) >= 0)
continue; // insert each vhdl component just one time
StringList.append(s);
QFileInfo Info(s);
if(Info.isRelative())
s = QucsWorkDir.filePath(s);
QFile f(s);
if(!f.open(IO_ReadOnly)) {
ErrText->insert(QObject::tr("ERROR: Cannot open VHDL file \"%1\".").
arg(s));
return false;
}
// Write the whole VHDL file into the netllist output.
QTextStream streamVHDL(&f);
s = streamVHDL.read();
f.close();
(*stream) << '\n' << s << '\n';
}
} // of "if(active)"
@ -945,6 +973,8 @@ bool Schematic::createSubNetlist(QTextStream *stream, int& countInit,
// write all components with node names into the netlist file
for(pc = DocComps.first(); pc != 0; pc = DocComps.next()) {
if(!pc->isActive) continue; // should it be simulated ?
if(pc->Model.at(0) == '.') { // no simulations in subcircuits
ErrText->insert(
QObject::tr("WARNING: Ignore simulation component in subcircuit \"%1\".").arg(DocName));

View File

@ -51,13 +51,14 @@ TextDoc::TextDoc(QucsApp *App_, const QString& Name_) : QucsDoc(App_, Name_)
setPaletteBackgroundColor(QucsSettings.BGColor);
connect(this, SIGNAL(textChanged()), SLOT(slotSetChanged()));
connect(this, SIGNAL(cursorPositionChanged(int, int)),
App, SLOT(slotPrintCursorPosition(int, int)));
SLOT(slotCursorPosChanged(int, int)));
connect(this, SIGNAL(undoAvailable(bool)), SLOT(slotChangeUndo(bool)));
connect(this, SIGNAL(redoAvailable(bool)), SLOT(slotChangeRedo(bool)));
syntaxHighlight = new SyntaxHighlighter(this);
}
tmpPosX = tmpPosY = 0;
Scale = (float)QucsSettings.font.pointSize();
undoIsAvailable = redoIsAvailable = false;
@ -88,7 +89,7 @@ void TextDoc::becomeCurrent(bool)
{
int x, y;
getCursorPosition(&x, &y);
App->slotPrintCursorPosition(x, y);
slotCursorPosChanged(x, y);
viewport()->setFocus();
if(undoIsAvailable) App->undo->setEnabled(true);
@ -97,6 +98,21 @@ void TextDoc::becomeCurrent(bool)
else App->redo->setEnabled(false);
}
// ---------------------------------------------------
void TextDoc::slotCursorPosChanged(int x, int y)
{
if(tmpPosX > x)
clearParagraphBackground(tmpPosX);
else
for(int z=tmpPosX; z<x; z++)
clearParagraphBackground(z);
if(tmpPosX != x)
setParagraphBackgroundColor(x, QColor(240, 240, 255));
App->printCursorPosition(x, y);
tmpPosX = x;
tmpPosY = y;
}
// ---------------------------------------------------
void TextDoc::slotSetChanged()
{
@ -122,6 +138,7 @@ bool TextDoc::load()
setModified(false);
slotSetChanged();
file.close();
lastSaved = QDateTime::currentDateTime();
return true;
}
@ -137,6 +154,7 @@ int TextDoc::save()
setModified(false);
slotSetChanged();
file.close();
lastSaved = QDateTime::currentDateTime();
return 0;
}
@ -199,12 +217,29 @@ float TextDoc::zoom(float s)
{
if(s < 1.0f) s = -1.0f/s;
Scale += s;
if(Scale > 40.0) Scale = 40.0f;
if(Scale < 4.0) Scale = 4.0f;
zoomTo((int)Scale);
if(Scale > 40.0f) Scale = 40.0f;
if(Scale < 4.0f) Scale = 4.0f;
zoomTo((int)(Scale+0.5f));
return Scale;
}
// ---------------------------------------------------
void TextDoc::showAll()
{
sync();
Scale *= float(visibleHeight()) / float(contentsHeight());
if(Scale > 40.0f) Scale = 40.0f;
if(Scale < 4.0f) Scale = 4.0f;
zoomTo((int)(Scale+0.5f));
}
// ---------------------------------------------------
void TextDoc::showNoZoom()
{
Scale = (float)QucsSettings.font.pointSize();
zoomTo(QucsSettings.font.pointSize());
}
// ---------------------------------------------------
bool TextDoc::loadSimulationTime(QString& Time)
{
@ -233,21 +268,23 @@ void TextDoc::slotChangeRedo(bool available)
// ---------------------------------------------------
void TextDoc::outcommmentSelected()
{
int i, paraStart, paraEnd, colStart, colEnd;
getSelection(&paraStart, &colStart, &paraEnd, &colEnd);
QString s = selectedText();
if(s.isEmpty())
return;
if(paraStart < 0) return; // no selection
if(colStart > 0) paraStart++;
if(colEnd < 1) paraEnd--;
if(paraStart > paraEnd) return; // no complete line selected
for(i=paraStart; i<=paraEnd; i++)
if(text(i).left(3) == "-- ") {
setSelection(i, 0, i, 3);
removeSelectedText();
if(s.left(2) == "--")
s.remove(0, 2);
else
s = "--" + s;
for(int i=s.length()-2; i>=0; i--)
if(s.at(i) == '\n') {
if(s.mid(i+1, 2) == "--")
s.remove(i+1, 2);
else
s.insert(i+1, "--");
}
else
insertAt("-- ", i, 0);
insert(s);
}
@ -272,11 +309,18 @@ int SyntaxHighlighter::highlightParagraph(const QString& text, int)
{
QChar c;
bool isFloat=false;
int iWord=-1, iNumber=-1, i=0;
int iString=-1, iWord=-1, iNumber=-1, iExpo=-1, i=0;
setFormat(0, text.length(), QucsSettings.font, QPen::black);
for(c = text.at(i); !c.isNull(); c = text.at(++i)) {
if(iWord >= 0) {
if(iString >= 0) {
setFormat(iString, i-iString+1, Qt::red);
if(c == '"')
iString = -1;
continue;
}
// ----- word that might become a reserved word --------------
else if(iWord >= 0) {
if(c.isLetterOrNumber())
continue;
if(c == '_')
@ -284,40 +328,72 @@ int SyntaxHighlighter::highlightParagraph(const QString& text, int)
markWord(text, iWord, i-iWord);
iWord = -1;
}
// ----- integer or floating point number --------------
else if(iNumber >= 0) {
if(c.isNumber())
continue;
if(c == '.') {
isFloat = true;
if(iExpo < 0) {
if(isFloat)
iNumber = -1;
isFloat = true;
}
else
iNumber = -1;
continue;
}
if((c == 'e') || (c == 'E')) {
if(iExpo < 0) {
iExpo = i;
isFloat = true;
}
else
iNumber = -1;
continue;
}
if((c == '-') || (c == '+')) {
if((iExpo+1) == i)
continue;
}
if(c != '_')
if(!c.isLetter()) {
if(isFloat)
setFormat(iNumber, i-iNumber, Qt::magenta);
setFormat(iNumber, i-iNumber, Qt::darkMagenta);
else
setFormat(iNumber, i-iNumber, Qt::blue);
}
iNumber = -1;
}
// ----- maybe a comment -------------------------------
else if(c == '-') {
if(i > 0)
if(text.at(i-1) == '-') { // VHDL comment starts with --
setFormat(i-1, text.length()-i, Qt::gray);
return 0;
}
continue;
}
// ----- no special syntax yet (or anymore) --------------
else {
if(c.isLetter())
iWord = i; // start a word
else if(c.isNumber()) {
iExpo = -1;
iNumber = i; // start a number
isFloat = false;
c = text.at(i-1);
if((c == '-') || (c == '+')) // include sign into number
iNumber--;
/* if((c == '-') || (c == '+')) // include sign into number
iNumber--;*/
}
}
if(c == '\'') {
if(i > 1)
if(text.at(i-2) == '\'')
setFormat(i-2, 3, Qt::magenta);
}
else if(c == '"')
iString = i;
}
return 0;
}
@ -381,7 +457,7 @@ void SyntaxHighlighter::markWord(const QString& text, int start, int len)
if(Word == *List) {
QFont boldFont = QucsSettings.font;
boldFont.setWeight(QFont::Bold);
setFormat(start, len, boldFont, Qt::magenta);
setFormat(start, len, boldFont, Qt::darkMagenta);
return;
}
}

View File

@ -50,11 +50,14 @@ public:
int save();
void print(QPrinter*, bool);
float zoom(float);
void showAll();
void showNoZoom();
void becomeCurrent(bool);
bool loadSimulationTime(QString&);
void outcommmentSelected();
public slots:
void slotCursorPosChanged(int, int);
void slotSetChanged();
void slotChangeUndo(bool);
void slotChangeRedo(bool);