25 #include <QTextStream>
41 Description = QObject::tr(
"Component taken from Qucs library");
49 QObject::tr(
"name of qucs library file")));
51 QObject::tr(
"name of component in library")));
58 p->
Props.first()->Value =
Props.first()->Value;
72 if(
tx == INT_MIN)
tx =
x1+4;
73 if(
ty == INT_MIN)
ty =
y2+4;
77 Lines.append(
new Line(-15, -15, 15, -15, QPen(Qt::darkBlue,2)));
78 Lines.append(
new Line( 15, -15, 15, 15, QPen(Qt::darkBlue,2)));
79 Lines.append(
new Line(-15, 15, 15, 15, QPen(Qt::darkBlue,2)));
80 Lines.append(
new Line(-15, -15,-15, 15, QPen(Qt::darkBlue,2)));
93 QStringList *Includes)
96 QFile file(Directory.absFilePath(
Props.first()->Value +
".lib"));
97 if(!file.open(QIODevice::ReadOnly))
100 QTextStream ReadWhole(&file);
101 Section = ReadWhole.read();
105 if(Section.left(14) !=
"<Qucs Library ")
108 int Start, End = Section.find(
' ', 14);
109 if(End < 15)
return -3;
110 QString
Line = Section.mid(14, End-14);
114 if(Name ==
"Symbol") {
115 Start = Section.find(
"\n<", 14);
117 if(Section.mid(Start+2, 14) ==
"DefaultSymbol>") {
119 End = Section.find(
"\n</DefaultSymbol>", Start);
120 if(End < 0)
return -9;
121 Section = Section.mid(Start, End-Start);
127 Line =
"\n<Component " +
Props.next()->Value +
">";
128 Start = Section.find(Line);
129 if(Start < 0)
return -4;
130 Start = Section.find(
'\n', Start);
131 if(Start < 0)
return -5;
133 End = Section.find(
"\n</Component>", Start);
134 if(End < 0)
return -6;
135 Section = Section.mid(Start, End-Start+1);
140 StartI = Section.find(
"<"+Name+
"Includes");
142 StartI = Section.find(
'"', StartI);
143 if(StartI < 0)
return -10;
144 EndI = Section.find(
'>', StartI);
145 if(EndI < 0)
return -11;
147 QString inc = Section.mid(StartI, EndI-StartI);
148 QStringList f = QStringList::split(QRegExp(
"\"\\s+\""), inc);
149 for(QStringList::Iterator it = f.begin(); it != f.end(); ++it ) {
150 Includes->append(*it);
156 Start = Section.find(
"<"+Name+
">");
157 if(Start < 0)
return -7;
158 Start = Section.find(
'\n', Start);
159 if(Start < 0)
return -8;
160 while(Section.at(++Start) ==
' ') ;
161 End = Section.find(
"</"+Name+
">", Start);
162 if(End < 0)
return -9;
165 Section = Section.mid(Start, End-Start);
175 QString FileString,
Line;
178 if(z != -7)
return z;
186 if(pc == 0)
return -20;
190 pc->
Arcs.setAutoDelete(
false);
191 pc->
Lines.setAutoDelete(
false);
192 pc->
Rects.setAutoDelete(
false);
193 pc->
Ellips.setAutoDelete(
false);
194 pc->
Ports.setAutoDelete(
false);
195 pc->
Texts.setAutoDelete(
false);
196 pc->
Props.setAutoDelete(
false);
207 QTextStream stream(&FileString, QIODevice::ReadOnly);
208 while(!stream.atEnd()) {
209 Line = stream.readLine();
210 Line = Line.stripWhiteSpace();
211 if(Line.isEmpty())
continue;
212 if(Line.at(0) !=
'<')
return -11;
213 if(Line.at(Line.length()-1) !=
'>')
return -12;
214 Line = Line.mid(1, Line.length()-2);
216 if(Result < 0)
return -13;
229 QString FileName = Directory.absFilePath(
Props.first()->Value);
239 QStringList Includes;
243 r =
loadSection(
"VHDLModel", FileString, &Includes);
245 r =
loadSection(
"VerilogModel", FileString, &Includes);
247 if(r < 0)
return false;
251 for(QStringList::Iterator it = Includes.begin();
252 it != Includes.end(); ++it ) {
254 if(FileList.findIndex(s) >= 0)
continue;
259 if(!file.open(QIODevice::ReadOnly)) {
262 QByteArray FileContent = file.readAll();
265 (*stream) << FileContent.data();
266 qDebug() <<
"hi from libcomp";
270 (*stream) <<
"\n" << FileString <<
"\n";
271 return error > 0 ?
false :
true;
284 QString s =
"Sub:"+
Name;
288 s +=
" "+p1->Connection->Name;
295 s +=
" "+pp->Name+
"=\""+pp->Value+
"\"";
308 for(pp =
Ports.next(); pp != 0; pp =
Ports.next())
318 QString s =
" " +
Name +
": entity Sub_" +
createType() +
" port map (";
323 for(pp =
Ports.next(); pp != 0; pp =
Ports.next())
QString properFileName(const QString &Name)
void copyComponent(Component *)
Q3PtrList< struct Arc > Arcs
tQucsSettings QucsSettings
Component * getComponentFromName(QString &Line, Schematic *p)
int analyseLine(const QString &, int)
bool checkVersion(QString &Line)
bool createSubNetlist(QTextStream *, QStringList &, int type=1)
Definitions and declarations for the main application.
QString properAbsFileName(const QString &Name)
Q3PtrList< Property > Props
void recreate(Schematic *)
int loadSection(const QString &, QString &, QStringList *i=0)
QString properName(const QString &Name)
QString getSubcircuitFile()