2009-11-08 16:33:19 +00:00
|
|
|
/***************************************************************************
|
|
|
|
module.cpp
|
|
|
|
------------
|
|
|
|
begin : Thu Nov 5 2009
|
|
|
|
copyright : (C) 2009 by Stefan Jahn
|
|
|
|
email : stefan@lkcc.org
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* *
|
|
|
|
* 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. *
|
|
|
|
* *
|
|
|
|
***************************************************************************/
|
2014-11-03 04:01:47 +08:00
|
|
|
#include <QHash>
|
2013-11-26 16:06:53 +01:00
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
2014-11-05 23:49:38 +08:00
|
|
|
#include <QList>
|
2014-11-04 12:48:23 +08:00
|
|
|
#include <QDebug>
|
2009-11-08 16:33:19 +00:00
|
|
|
|
|
|
|
#include "element.h"
|
|
|
|
#include "components/component.h"
|
|
|
|
#include "components/components.h"
|
2016-01-17 19:55:13 +03:00
|
|
|
#include "spicecomponents/spicecomponents.h"
|
2009-11-08 16:33:19 +00:00
|
|
|
#include "paintings/paintings.h"
|
|
|
|
#include "diagrams/diagrams.h"
|
|
|
|
#include "module.h"
|
2016-01-09 14:36:32 +03:00
|
|
|
#include "main.h"
|
|
|
|
#include "extsimkernels/spicecompat.h"
|
2009-11-08 16:33:19 +00:00
|
|
|
|
|
|
|
// Global category and component lists.
|
2014-11-03 04:01:47 +08:00
|
|
|
QHash<QString, Module *> Module::Modules;
|
2014-11-05 23:49:38 +08:00
|
|
|
QList<Category *> Category::Categories;
|
2009-11-08 16:33:19 +00:00
|
|
|
|
2014-02-26 21:29:09 +01:00
|
|
|
QMap<QString, QString> Module::vaComponents;
|
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
// Constructor creates instance of module object.
|
|
|
|
Module::Module () {
|
|
|
|
info = 0;
|
|
|
|
category = "#special";
|
2023-10-19 19:39:31 +03:00
|
|
|
icon = nullptr;
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Destructor removes instance of module object from memory.
|
|
|
|
Module::~Module () {
|
2023-10-19 19:39:31 +03:00
|
|
|
if (icon != nullptr) delete icon;
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Module registration using a category name and the appropriate
|
|
|
|
// function returning a modules instance object.
|
|
|
|
void Module::registerModule (QString category, pInfoFunc info) {
|
|
|
|
Module * m = new Module ();
|
|
|
|
m->info = info;
|
|
|
|
m->category = category;
|
|
|
|
intoCategory (m);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Component registration using a category name and the appropriate
|
|
|
|
// function returning a components instance object.
|
2023-06-15 19:24:02 +03:00
|
|
|
void Module::registerComponent(QString category, pInfoFunc info) {
|
2024-09-24 00:25:48 +03:00
|
|
|
|
|
|
|
// instantiation of the component once in order to obtain "Model"
|
|
|
|
// property of the component
|
|
|
|
QString Name;
|
|
|
|
char* File;
|
|
|
|
Component* c = (Component*)info(Name, File, true);
|
|
|
|
|
|
|
|
// put into category and the component hash
|
|
|
|
if ((c->Simulator & QucsSettings.DefaultSimulator) ==
|
|
|
|
QucsSettings.DefaultSimulator) {
|
|
|
|
Module* m = new Module();
|
|
|
|
m->info = info;
|
|
|
|
m->category = category;
|
|
|
|
|
|
|
|
m->icon = new QPixmap(128, 128);
|
2023-10-19 19:39:31 +03:00
|
|
|
c->paintIcon(m->icon);
|
|
|
|
|
2024-09-24 00:25:48 +03:00
|
|
|
intoCategory(m);
|
|
|
|
if (!Modules.contains(c->Model)) {
|
|
|
|
Modules.insert(c->Model, m);
|
2023-06-15 19:24:02 +03:00
|
|
|
}
|
2024-09-24 00:25:48 +03:00
|
|
|
}
|
|
|
|
delete c;
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns instantiated component based on the given "Model" name. If
|
|
|
|
// there is no such component registers the function returns NULL.
|
|
|
|
Component * Module::getComponent (QString Model) {
|
2014-11-11 21:26:35 +01:00
|
|
|
if ( Modules.contains(Model)) {
|
|
|
|
Module *m = Modules.find(Model).value();
|
2009-11-08 16:33:19 +00:00
|
|
|
QString Name;
|
|
|
|
char * File;
|
2014-03-02 22:50:12 +01:00
|
|
|
QString vaBitmap;
|
2014-02-26 21:29:09 +01:00
|
|
|
if (vaComponents.contains(Model))
|
|
|
|
return (Component *)
|
2014-03-02 22:50:12 +01:00
|
|
|
vacomponent::info (Name, vaBitmap, true, vaComponents[Model]);
|
2014-02-26 21:29:09 +01:00
|
|
|
else
|
|
|
|
return (Component *) m->info (Name, File, true);
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-19 22:01:06 +01:00
|
|
|
void Module::registerDynamicComponents()
|
|
|
|
{
|
|
|
|
qDebug() << "Module::registerDynamicComponents()";
|
|
|
|
|
2014-03-05 15:33:06 +01:00
|
|
|
|
2014-03-02 22:50:12 +01:00
|
|
|
// vaComponents is populated in QucsApp::slotLoadModule
|
2014-02-19 22:01:06 +01:00
|
|
|
|
2014-03-02 22:50:12 +01:00
|
|
|
// register modules symbol and properties out of in vaComponents
|
2014-02-26 21:29:09 +01:00
|
|
|
QMapIterator<QString, QString> i(vaComponents);
|
|
|
|
while (i.hasNext()) {
|
|
|
|
i.next();
|
|
|
|
|
2014-03-05 15:33:06 +01:00
|
|
|
// qDebug() << i.key() << ": " << i.value() << endl;
|
2014-02-26 21:29:09 +01:00
|
|
|
|
|
|
|
Module * m = new Module ();
|
|
|
|
|
|
|
|
// what now? pointer to info?
|
|
|
|
|
|
|
|
// the typedef needs to be different
|
|
|
|
//passes the pointer, but it has no idea how to call the JSON
|
|
|
|
m->infoVA = &vacomponent::info;
|
|
|
|
|
|
|
|
// TODO maybe allow user load into custom category?
|
|
|
|
m->category = QObject::tr("verilog-a user devices");
|
|
|
|
|
|
|
|
// instantiation of the component once in order
|
|
|
|
// to obtain "Model" property of the component
|
|
|
|
//QString Name, Model;
|
|
|
|
//char * File;
|
2014-03-02 22:50:12 +01:00
|
|
|
QString Name, Model, vaBitmap;
|
|
|
|
// char * File;
|
2014-02-26 21:29:09 +01:00
|
|
|
Component * c = (Component *)
|
2014-03-02 22:50:12 +01:00
|
|
|
vacomponent::info (Name, vaBitmap, true, vaComponents[i.key()]);
|
2014-02-26 21:29:09 +01:00
|
|
|
Model = c->Model;
|
|
|
|
delete c;
|
|
|
|
|
|
|
|
// put into category and the component hash
|
|
|
|
intoCategory (m);
|
|
|
|
|
2014-11-03 04:01:47 +08:00
|
|
|
if (!Modules.contains (Model))
|
2014-02-26 21:29:09 +01:00
|
|
|
Modules.insert (Model, m);
|
|
|
|
|
|
|
|
} // while
|
2014-02-19 22:01:06 +01:00
|
|
|
}
|
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
// The function appends the given module to the appropriate category.
|
|
|
|
// If there is no such category yet, then the category gets created.
|
|
|
|
void Module::intoCategory (Module * m) {
|
|
|
|
|
|
|
|
// look through existing categories
|
2014-11-05 23:49:38 +08:00
|
|
|
QList<Category *>::const_iterator it;
|
|
|
|
for (it = Category::Categories.constBegin();
|
|
|
|
it != Category::Categories.constEnd(); it++) {
|
|
|
|
if ((*it)->Name == m->category) {
|
|
|
|
(*it)->Content.append (m);
|
2009-11-08 16:33:19 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if there is no such category, then create it
|
2014-11-05 23:49:38 +08:00
|
|
|
if (it == Category::Categories.constEnd()) {
|
|
|
|
Category *cat = new Category (m->category);
|
2009-11-08 16:33:19 +00:00
|
|
|
Category::Categories.append (cat);
|
|
|
|
cat->Content.append (m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper macros for module registration.
|
|
|
|
#define REGISTER_MOD_1(cat,val) \
|
|
|
|
registerModule (cat, &val::info)
|
|
|
|
#define REGISTER_MOD_2(cat,val,inf1,inf2) \
|
|
|
|
registerModule (cat, &val::inf1); \
|
|
|
|
registerModule (cat, &val::inf2)
|
|
|
|
#define REGISTER_MOD_3(cat,val,inf1,inf2,inf3) \
|
|
|
|
registerModule (cat, &val::inf1); \
|
|
|
|
registerModule (cat, &val::inf2); \
|
|
|
|
registerModule (cat, &val::inf3)
|
|
|
|
|
|
|
|
#define REGISTER_COMP_1(cat,val) \
|
|
|
|
registerComponent (cat, &val::info)
|
2024-01-04 22:28:08 +03:00
|
|
|
#define REGISTER_SPECIFIC_COMP_1(cat,val,inf1) \
|
|
|
|
registerComponent (cat, &val::inf1)
|
2009-11-08 16:33:19 +00:00
|
|
|
#define REGISTER_COMP_2(cat,val,inf1,inf2) \
|
|
|
|
registerComponent (cat, &val::inf1); \
|
|
|
|
registerComponent (cat, &val::inf2)
|
|
|
|
#define REGISTER_COMP_3(cat,val,inf1,inf2,inf3) \
|
|
|
|
registerComponent (cat, &val::inf1); \
|
|
|
|
registerComponent (cat, &val::inf2); \
|
|
|
|
registerComponent (cat, &val::inf3)
|
|
|
|
|
|
|
|
#define REGISTER_LUMPED_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("lumped components"),val)
|
|
|
|
#define REGISTER_LUMPED_2(val,inf1,inf2) \
|
|
|
|
REGISTER_COMP_2 (QObject::tr("lumped components"),val,inf1,inf2)
|
|
|
|
#define REGISTER_SOURCE_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("sources"),val)
|
|
|
|
#define REGISTER_PROBE_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("probes"),val)
|
2024-02-24 11:07:46 +03:00
|
|
|
#define REGISTER_RF_COMP_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("RF components"),val)
|
2009-11-08 16:33:19 +00:00
|
|
|
#define REGISTER_TRANS_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("transmission lines"),val)
|
|
|
|
#define REGISTER_NONLINEAR_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("nonlinear components"),val)
|
|
|
|
#define REGISTER_NONLINEAR_2(val,inf1,inf2) \
|
|
|
|
REGISTER_COMP_2 (QObject::tr("nonlinear components"),val,inf1,inf2)
|
|
|
|
#define REGISTER_NONLINEAR_3(val,inf1,inf2,inf3) \
|
|
|
|
REGISTER_COMP_3 (QObject::tr("nonlinear components"),val,inf1,inf2,inf3)
|
2024-01-05 09:48:26 +03:00
|
|
|
#define REGISTER_MICROEL_1(val,inf1) \
|
|
|
|
REGISTER_SPECIFIC_COMP_1 (QObject::tr("microelectronics"),val,inf1)
|
|
|
|
#define REGISTER_MICROEL_2(val,inf1,inf2) \
|
|
|
|
REGISTER_COMP_2 (QObject::tr("microelectronics"),val,inf1,inf2)
|
2009-11-08 16:33:19 +00:00
|
|
|
#define REGISTER_VERILOGA_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("verilog-a devices"),val)
|
|
|
|
#define REGISTER_VERILOGA_2(val,inf1,inf2) \
|
|
|
|
REGISTER_COMP_2 (QObject::tr("verilog-a devices"),val,inf1,inf2)
|
|
|
|
#define REGISTER_DIGITAL_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("digital components"),val)
|
|
|
|
#define REGISTER_FILE_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("file components"),val)
|
|
|
|
#define REGISTER_FILE_3(val,inf1,inf2,inf3) \
|
|
|
|
REGISTER_COMP_3 (QObject::tr("file components"),val,inf1,inf2,inf3)
|
|
|
|
#define REGISTER_SIMULATION_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("simulations"),val)
|
|
|
|
#define REGISTER_DIAGRAM_1(val) \
|
|
|
|
REGISTER_MOD_1 (QObject::tr("diagrams"),val)
|
2022-08-06 15:30:27 +03:00
|
|
|
#define REGISTER_EQUATION_1(val) \
|
|
|
|
REGISTER_MOD_1 (QObject::tr("equations"),val)
|
2009-11-08 16:33:19 +00:00
|
|
|
#define REGISTER_DIAGRAM_2(val,inf1,inf2) \
|
|
|
|
REGISTER_MOD_2 (QObject::tr("diagrams"),val,inf1,inf2)
|
|
|
|
#define REGISTER_PAINT_1(val) \
|
|
|
|
REGISTER_MOD_1 (QObject::tr("paintings"),val)
|
|
|
|
#define REGISTER_PAINT_2(val,inf1,inf2) \
|
|
|
|
REGISTER_MOD_2 (QObject::tr("paintings"),val,inf1,inf2)
|
2014-01-10 13:29:56 +00:00
|
|
|
#define REGISTER_EXTERNAL_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("external sim components"),val)
|
2015-02-24 15:43:38 +03:00
|
|
|
#define REGISTER_SPICE_1(val) \
|
2015-09-27 13:02:34 +01:00
|
|
|
REGISTER_COMP_1 (QObject::tr("SPICE components"),val)
|
2015-03-29 18:53:58 +03:00
|
|
|
#define REGISTER_SPICE_SEC_1(val) \
|
2023-12-26 21:14:50 +03:00
|
|
|
REGISTER_COMP_1 (QObject::tr("SPICE netlist sections"),val)
|
2015-04-06 16:19:32 +03:00
|
|
|
#define REGISTER_SPICE_SIM_1(val) \
|
2015-09-27 13:02:34 +01:00
|
|
|
REGISTER_COMP_1 (QObject::tr("SPICE simulations"),val)
|
2016-05-03 13:37:11 +03:00
|
|
|
#define REGISTER_XSPICE_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("XSPICE devices"),val)
|
2016-01-09 14:36:32 +03:00
|
|
|
#define REGISTER_QUCS_1(val) \
|
|
|
|
REGISTER_COMP_1 (QObject::tr("Qucs legacy devices"),val)
|
|
|
|
#define REGISTER_QUCS_2(val,inf1,inf2) \
|
|
|
|
REGISTER_COMP_2 (QObject::tr("Qucs legacy devices"),val,inf1,inf2)
|
|
|
|
#define REGISTER_QUCS_3(val,inf1,inf2,inf3) \
|
|
|
|
REGISTER_COMP_3 (QObject::tr("Qucs legacy devices"),val,inf1,inf2,inf3)
|
2009-11-08 16:33:19 +00:00
|
|
|
|
|
|
|
// This function has to be called once at application startup. It
|
|
|
|
// registers every component available in the application. Put here
|
|
|
|
// any new component.
|
|
|
|
void Module::registerModules (void) {
|
2023-06-09 13:54:29 +03:00
|
|
|
unregisterModules();
|
2009-11-08 16:33:19 +00:00
|
|
|
|
|
|
|
REGISTER_LUMPED_2 (Resistor, info, info_us);
|
|
|
|
REGISTER_LUMPED_1 (Capacitor);
|
|
|
|
REGISTER_LUMPED_1 (Inductor);
|
2023-03-03 17:10:15 +03:00
|
|
|
REGISTER_LUMPED_1 (IndQ);
|
|
|
|
REGISTER_LUMPED_1 (CapQ);
|
2023-12-01 18:18:59 +03:00
|
|
|
REGISTER_LUMPED_1 (potentiometer);
|
2023-10-15 14:24:48 +03:00
|
|
|
REGISTER_LUMPED_1 (Mutual);
|
|
|
|
REGISTER_LUMPED_1 (Mutual2);
|
|
|
|
REGISTER_LUMPED_1 (MutualX);
|
2009-11-08 16:33:19 +00:00
|
|
|
// lumped components
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator != spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_LUMPED_1 (R_SPICE);
|
|
|
|
REGISTER_LUMPED_1 (C_SPICE);
|
|
|
|
REGISTER_LUMPED_1 (L_SPICE);
|
|
|
|
REGISTER_LUMPED_1 (K_SPICE);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_LUMPED_1 (Transformer);
|
|
|
|
REGISTER_LUMPED_1 (symTrafo);
|
2023-10-15 14:24:48 +03:00
|
|
|
REGISTER_LUMPED_1 (Ground);
|
|
|
|
REGISTER_LUMPED_1 (SubCirPort);
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_LUMPED_1 (Gyrator);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
REGISTER_LUMPED_1 (iProbe);
|
|
|
|
REGISTER_LUMPED_1 (vProbe);
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_LUMPED_1 (Switch);
|
2023-06-09 13:54:29 +03:00
|
|
|
//} else {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_LUMPED_1 (S4Q_S);
|
|
|
|
REGISTER_LUMPED_1 (S4Q_W);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
REGISTER_LUMPED_1 (Relais);
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
// sources
|
|
|
|
REGISTER_SOURCE_1 (Volt_dc);
|
|
|
|
REGISTER_SOURCE_1 (Ampere_dc);
|
|
|
|
REGISTER_SOURCE_1 (Volt_ac);
|
|
|
|
REGISTER_SOURCE_1 (Ampere_ac);
|
2022-03-12 18:04:35 +01:00
|
|
|
REGISTER_SOURCE_1 (Source_ac);
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_SOURCE_1 (Volt_noise);
|
|
|
|
REGISTER_SOURCE_1 (Ampere_noise);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2009-11-08 16:33:19 +00:00
|
|
|
REGISTER_SOURCE_1 (VCCS);
|
|
|
|
REGISTER_SOURCE_1 (CCCS);
|
|
|
|
REGISTER_SOURCE_1 (VCVS);
|
|
|
|
REGISTER_SOURCE_1 (CCVS);
|
|
|
|
REGISTER_SOURCE_1 (vPulse);
|
|
|
|
REGISTER_SOURCE_1 (iPulse);
|
|
|
|
REGISTER_SOURCE_1 (vRect);
|
|
|
|
REGISTER_SOURCE_1 (iRect);
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_SOURCE_1 (Noise_ii);
|
|
|
|
REGISTER_SOURCE_1 (Noise_vv);
|
|
|
|
REGISTER_SOURCE_1 (Noise_iv);
|
|
|
|
REGISTER_SOURCE_1 (AM_Modulator);
|
|
|
|
REGISTER_SOURCE_1 (PM_Modulator);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
REGISTER_SOURCE_1 (iExp);
|
|
|
|
REGISTER_SOURCE_1 (vExp);
|
2023-04-18 16:03:16 +03:00
|
|
|
REGISTER_SOURCE_1 (vFile);
|
|
|
|
REGISTER_SOURCE_1 (iFile);
|
2009-11-08 16:33:19 +00:00
|
|
|
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator != spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_SOURCE_1 (S4Q_V);
|
|
|
|
REGISTER_SOURCE_1 (S4Q_I);
|
|
|
|
REGISTER_SOURCE_1 (Src_eqndef);
|
|
|
|
REGISTER_SOURCE_1 (S4Q_Ieqndef);
|
|
|
|
REGISTER_SOURCE_1 (vPWL);
|
|
|
|
REGISTER_SOURCE_1 (iPWL);
|
|
|
|
REGISTER_SOURCE_1 (vSffm);
|
|
|
|
REGISTER_SOURCE_1 (iSffm);
|
|
|
|
REGISTER_SOURCE_1 (eNL);
|
|
|
|
REGISTER_SOURCE_1 (gNL);
|
|
|
|
REGISTER_SOURCE_1 (vAmpMod);
|
|
|
|
REGISTER_SOURCE_1 (iAmpMod);
|
|
|
|
REGISTER_SOURCE_1 (vTRNOISE);
|
|
|
|
REGISTER_SOURCE_1 (iTRNOISE);
|
|
|
|
REGISTER_SOURCE_1 (vTRRANDOM);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2015-03-25 10:36:06 +00:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
// probes
|
|
|
|
REGISTER_PROBE_1 (iProbe);
|
|
|
|
REGISTER_PROBE_1 (vProbe);
|
|
|
|
|
2024-02-24 11:07:46 +03:00
|
|
|
// RF devices except transmission line
|
2024-08-16 19:57:47 +03:00
|
|
|
REGISTER_RF_COMP_1 (IndQ);
|
|
|
|
REGISTER_RF_COMP_1 (CapQ);
|
2024-02-24 11:07:46 +03:00
|
|
|
REGISTER_RF_COMP_1 (dcBlock);
|
|
|
|
REGISTER_RF_COMP_1 (dcFeed);
|
|
|
|
REGISTER_RF_COMP_1 (circularloop);
|
|
|
|
REGISTER_RF_COMP_1 (spiralinductor);
|
|
|
|
REGISTER_RF_COMP_1 (BiasT);
|
|
|
|
REGISTER_RF_COMP_1 (Attenuator);
|
|
|
|
REGISTER_RF_COMP_1 (Amplifier);
|
|
|
|
REGISTER_RF_COMP_1 (Isolator);
|
|
|
|
REGISTER_RF_COMP_1 (Circulator);
|
|
|
|
REGISTER_RF_COMP_1 (Phaseshifter);
|
|
|
|
REGISTER_RF_COMP_1 (Coupler);
|
|
|
|
REGISTER_RF_COMP_1 (Hybrid);
|
|
|
|
REGISTER_RF_COMP_1 (RFedd);
|
|
|
|
REGISTER_RF_COMP_1 (RFedd2P);
|
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
// transmission lines
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_TRANS_1 (TLine);
|
|
|
|
REGISTER_TRANS_1 (TLine_4Port);
|
|
|
|
REGISTER_TRANS_1 (CoupledTLine);
|
|
|
|
REGISTER_TRANS_1 (TwistedPair);
|
|
|
|
REGISTER_TRANS_1 (CoaxialLine);
|
|
|
|
REGISTER_TRANS_1 (RectLine);
|
2023-10-13 16:08:03 +03:00
|
|
|
REGISTER_TRANS_1 (CircLine);
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_TRANS_1 (RLCG);
|
2023-10-13 16:29:01 +03:00
|
|
|
REGISTER_TRANS_1 (taperedline);
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_TRANS_1 (Substrate);
|
|
|
|
REGISTER_TRANS_1 (MSline);
|
|
|
|
REGISTER_TRANS_1 (MScoupled);
|
|
|
|
REGISTER_TRANS_1 (MSlange);
|
|
|
|
REGISTER_TRANS_1 (MScorner);
|
|
|
|
REGISTER_TRANS_1 (MSmbend);
|
|
|
|
REGISTER_TRANS_1 (MSstep);
|
|
|
|
REGISTER_TRANS_1 (MStee);
|
|
|
|
REGISTER_TRANS_1 (MScross);
|
|
|
|
REGISTER_TRANS_1 (MSopen);
|
|
|
|
REGISTER_TRANS_1 (MSgap);
|
|
|
|
REGISTER_TRANS_1 (MSvia);
|
|
|
|
REGISTER_TRANS_1 (MSrstub);
|
|
|
|
REGISTER_TRANS_1 (Coplanar);
|
|
|
|
REGISTER_TRANS_1 (CPWopen);
|
|
|
|
REGISTER_TRANS_1 (CPWshort);
|
|
|
|
REGISTER_TRANS_1 (CPWgap);
|
|
|
|
REGISTER_TRANS_1 (CPWstep);
|
|
|
|
REGISTER_TRANS_1 (BondWire);
|
2023-06-09 13:54:29 +03:00
|
|
|
//} else {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_TRANS_1 (LTL_SPICE);
|
|
|
|
REGISTER_TRANS_1 (LTRA_SPICE);
|
|
|
|
REGISTER_TRANS_1 (UDRCTL_SPICE);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
|
|
|
|
// nonlinear components
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_NONLINEAR_1 (Diode);
|
|
|
|
REGISTER_NONLINEAR_2 (BJT, info, info_pnp);
|
|
|
|
REGISTER_NONLINEAR_2 (BJTsub, info, info_pnp);
|
|
|
|
REGISTER_NONLINEAR_2 (JFET, info, info_p);
|
|
|
|
REGISTER_NONLINEAR_3 (MOSFET, info, info_p, info_depl);
|
|
|
|
REGISTER_NONLINEAR_3 (MOSFET_sub, info, info_p, info_depl);
|
2023-06-09 13:54:29 +03:00
|
|
|
//} else {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_NONLINEAR_1 (MESFET_SPICE);
|
|
|
|
REGISTER_NONLINEAR_1 (PMF_MESFET_SPICE);
|
|
|
|
REGISTER_NONLINEAR_1 (S4Q_Ieqndef);
|
|
|
|
REGISTER_NONLINEAR_1 (Src_eqndef);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
REGISTER_NONLINEAR_1 (OpAmp);
|
|
|
|
REGISTER_NONLINEAR_1 (EqnDefined);
|
2024-10-23 20:07:54 +03:00
|
|
|
REGISTER_NONLINEAR_1 (vcresistor);
|
2016-05-15 10:09:41 +03:00
|
|
|
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_NONLINEAR_1 (Diac);
|
|
|
|
REGISTER_NONLINEAR_1 (Triac);
|
|
|
|
REGISTER_NONLINEAR_1 (Thyristor);
|
|
|
|
REGISTER_NONLINEAR_1 (TunnelDiode);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2024-01-04 22:28:08 +03:00
|
|
|
// PDK devices
|
2024-01-05 09:48:26 +03:00
|
|
|
REGISTER_MICROEL_1 (R_SPICE, info_R3);
|
|
|
|
REGISTER_MICROEL_1 (C_SPICE, info_C3);
|
2024-07-03 15:09:34 +03:00
|
|
|
REGISTER_MICROEL_1 (DIODE_SPICE, info);
|
2024-01-05 09:48:26 +03:00
|
|
|
REGISTER_MICROEL_1 (DIODE_SPICE, info_DIODE3);
|
|
|
|
REGISTER_MICROEL_1 (NMOS_SPICE, info);
|
|
|
|
REGISTER_MICROEL_1 (PMOS_SPICE, info);
|
|
|
|
REGISTER_MICROEL_2 (MOS_SPICE,info_NM3pin,info_PM3pin);
|
|
|
|
REGISTER_MICROEL_2 (MOS_SPICE,info_NX3pin,info_PX3pin);
|
|
|
|
REGISTER_MICROEL_2 (MOS_SPICE,info_NX4pin,info_PX4pin);
|
2024-07-03 15:09:34 +03:00
|
|
|
REGISTER_MICROEL_1 (NJF_SPICE, info);
|
|
|
|
REGISTER_MICROEL_1 (PJF_SPICE, info);
|
|
|
|
REGISTER_MICROEL_1 (NPN_SPICE, info);
|
|
|
|
REGISTER_MICROEL_1 (PNP_SPICE, info);
|
2024-01-05 09:48:26 +03:00
|
|
|
REGISTER_MICROEL_2 (BJT_SPICE,infoNPN4,infoPNP4);
|
|
|
|
REGISTER_MICROEL_2 (BJT_SPICE,infoNPN5,infoPNP5);
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
// verilog-a devices
|
|
|
|
REGISTER_VERILOGA_1 (mod_amp);
|
|
|
|
REGISTER_VERILOGA_1 (log_amp);
|
|
|
|
REGISTER_VERILOGA_1 (MESFET);
|
|
|
|
REGISTER_VERILOGA_1 (photodiode);
|
|
|
|
REGISTER_VERILOGA_1 (phototransistor);
|
|
|
|
REGISTER_VERILOGA_1 (nigbt);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2023-05-25 10:12:45 +03:00
|
|
|
// digital components
|
|
|
|
REGISTER_DIGITAL_1 (Digi_Sim);
|
|
|
|
REGISTER_DIGITAL_1 (Digi_Source);
|
|
|
|
REGISTER_DIGITAL_1 (Logical_Buf);
|
|
|
|
REGISTER_DIGITAL_1 (Logical_Inv);
|
|
|
|
REGISTER_DIGITAL_1 (Logical_NAND);
|
|
|
|
REGISTER_DIGITAL_1 (Logical_OR);
|
|
|
|
REGISTER_DIGITAL_1 (Logical_NOR);
|
|
|
|
REGISTER_DIGITAL_1 (Logical_AND);
|
|
|
|
REGISTER_DIGITAL_1 (Logical_XOR);
|
|
|
|
REGISTER_DIGITAL_1 (Logical_XNOR);
|
|
|
|
REGISTER_DIGITAL_1 (D_FlipFlop);
|
|
|
|
REGISTER_DIGITAL_1 (dff_SR);
|
|
|
|
REGISTER_DIGITAL_1 (jkff_SR);
|
|
|
|
REGISTER_DIGITAL_1 (tff_SR);
|
|
|
|
REGISTER_DIGITAL_1 (andor4x2);
|
|
|
|
REGISTER_DIGITAL_1 (andor4x3);
|
|
|
|
REGISTER_DIGITAL_1 (andor4x4);
|
|
|
|
REGISTER_DIGITAL_1 (mux2to1);
|
|
|
|
REGISTER_DIGITAL_1 (mux4to1);
|
|
|
|
REGISTER_DIGITAL_1 (mux8to1);
|
|
|
|
REGISTER_DIGITAL_1 (dmux2to4);
|
|
|
|
REGISTER_DIGITAL_1 (dmux3to8);
|
|
|
|
REGISTER_DIGITAL_1 (dmux4to16);
|
|
|
|
REGISTER_DIGITAL_1 (ha1b);
|
|
|
|
REGISTER_DIGITAL_1 (fa1b);
|
|
|
|
REGISTER_DIGITAL_1 (fa2b);
|
|
|
|
REGISTER_DIGITAL_1 (RS_FlipFlop);
|
|
|
|
REGISTER_DIGITAL_1 (JK_FlipFlop);
|
|
|
|
REGISTER_DIGITAL_1 (gatedDlatch);
|
|
|
|
REGISTER_DIGITAL_1 (logic_0);
|
|
|
|
REGISTER_DIGITAL_1 (logic_1);
|
|
|
|
REGISTER_DIGITAL_1 (pad2bit);
|
|
|
|
REGISTER_DIGITAL_1 (pad3bit);
|
|
|
|
REGISTER_DIGITAL_1 (pad4bit);
|
2023-05-29 14:18:22 +03:00
|
|
|
//REGISTER_DIGITAL_1 (DLS_nto1);
|
|
|
|
//REGISTER_DIGITAL_1 (DLS_1ton);
|
2023-05-25 10:12:45 +03:00
|
|
|
REGISTER_DIGITAL_1 (binarytogrey4bit);
|
|
|
|
REGISTER_DIGITAL_1 (greytobinary4bit);
|
|
|
|
REGISTER_DIGITAL_1 (comp_1bit);
|
|
|
|
REGISTER_DIGITAL_1 (comp_2bit);
|
|
|
|
REGISTER_DIGITAL_1 (comp_4bit);
|
|
|
|
REGISTER_DIGITAL_1 (hpribin4bit);
|
|
|
|
REGISTER_DIGITAL_1 (VHDL_File);
|
|
|
|
REGISTER_DIGITAL_1 (Verilog_File);
|
2009-11-08 16:33:19 +00:00
|
|
|
|
|
|
|
// file components
|
|
|
|
REGISTER_FILE_1 (Subcircuit);
|
2024-06-14 19:22:46 +03:00
|
|
|
REGISTER_FILE_1 (SpiceLibComp);
|
|
|
|
REGISTER_FILE_1 (SpiceFile);
|
|
|
|
REGISTER_FILE_3 (SParamFile, info1, info2, info);
|
|
|
|
REGISTER_FILE_1 (SpiceGeneric);
|
|
|
|
REGISTER_FILE_1 (XspiceGeneric);
|
2016-09-03 17:32:11 +03:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
// simulations
|
|
|
|
REGISTER_SIMULATION_1 (DC_Sim);
|
|
|
|
REGISTER_SIMULATION_1 (TR_Sim);
|
|
|
|
REGISTER_SIMULATION_1 (AC_Sim);
|
2022-04-02 19:39:55 +02:00
|
|
|
REGISTER_SIMULATION_1 (SP_Sim);
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator|| QucsSettings.DefaultSimulator == spicecompat::simXyce) {
|
2016-08-21 15:09:44 +03:00
|
|
|
REGISTER_SIMULATION_1 (HB_Sim);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2009-11-08 16:33:19 +00:00
|
|
|
REGISTER_SIMULATION_1 (Param_Sweep);
|
|
|
|
REGISTER_SIMULATION_1 (Digi_Sim);
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator)
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_SIMULATION_1 (Optimize_Sim);
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator != spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_SIMULATION_1 (SpiceFourier);
|
2016-08-21 15:09:44 +03:00
|
|
|
REGISTER_SIMULATION_1 (SpiceNoise);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simNgspice || QucsSettings.DefaultSimulator == spicecompat::simSpiceOpus) {
|
2022-05-11 21:39:10 +03:00
|
|
|
REGISTER_SIMULATION_1 (SpiceFFT);
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_SIMULATION_1 (SpiceDisto);
|
|
|
|
REGISTER_SIMULATION_1 (SpiceCustomSim);
|
|
|
|
REGISTER_SIMULATION_1 (SpicePZ);
|
2017-09-11 16:09:23 +03:00
|
|
|
REGISTER_SIMULATION_1 (SpiceSENS);
|
2017-09-14 16:54:01 +03:00
|
|
|
REGISTER_SIMULATION_1 (SpiceSENS_AC);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2009-11-08 16:33:19 +00:00
|
|
|
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simXyce) {
|
2016-06-22 14:10:05 +03:00
|
|
|
REGISTER_SIMULATION_1 (XyceScript);
|
2017-09-18 12:55:09 +03:00
|
|
|
REGISTER_SIMULATION_1 (SpiceSENS_Xyce);
|
2017-09-27 10:52:43 +03:00
|
|
|
REGISTER_SIMULATION_1 (SpiceSENS_TR_Xyce);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2016-06-22 14:10:05 +03:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
// diagrams
|
|
|
|
REGISTER_DIAGRAM_1 (RectDiagram);
|
|
|
|
REGISTER_DIAGRAM_1 (PolarDiagram);
|
|
|
|
REGISTER_DIAGRAM_1 (TabDiagram);
|
|
|
|
REGISTER_DIAGRAM_2 (SmithDiagram, info, info_y);
|
|
|
|
REGISTER_DIAGRAM_2 (PSDiagram, info, info_sp);
|
|
|
|
REGISTER_DIAGRAM_1 (Rect3DDiagram);
|
|
|
|
REGISTER_DIAGRAM_1 (CurveDiagram);
|
|
|
|
REGISTER_DIAGRAM_1 (TimingDiagram);
|
|
|
|
REGISTER_DIAGRAM_1 (TruthDiagram);
|
|
|
|
|
2022-08-06 15:30:27 +03:00
|
|
|
// equations
|
|
|
|
REGISTER_EQUATION_1 (NutmegEquation);
|
|
|
|
REGISTER_EQUATION_1 (SpiceParam);
|
2024-12-14 13:26:36 +03:00
|
|
|
REGISTER_EQUATION_1 (SpiceCSParam);
|
2022-08-06 15:30:27 +03:00
|
|
|
REGISTER_EQUATION_1 (SpiceGlobalParam);
|
|
|
|
REGISTER_EQUATION_1 (Equation);
|
|
|
|
|
2014-01-10 13:29:56 +00:00
|
|
|
// external simulation
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator == spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_EXTERNAL_1 (ETR_Sim);
|
|
|
|
REGISTER_EXTERNAL_1 (ecvs);
|
2023-06-09 13:54:29 +03:00
|
|
|
//}
|
2015-04-06 16:19:32 +03:00
|
|
|
|
2023-06-09 13:54:29 +03:00
|
|
|
//if (QucsSettings.DefaultSimulator != spicecompat::simQucsator) {
|
2016-01-09 14:36:32 +03:00
|
|
|
// XSPICE analogue component blocks
|
2016-05-03 13:37:11 +03:00
|
|
|
REGISTER_XSPICE_1 (Icouple);
|
|
|
|
REGISTER_XSPICE_1 (core);
|
|
|
|
REGISTER_XSPICE_1 (SDTF);
|
|
|
|
REGISTER_XSPICE_1 (XAPWL);
|
2016-01-09 14:36:32 +03:00
|
|
|
|
2016-01-21 10:27:43 +03:00
|
|
|
// XSPICE file devices
|
2016-05-03 13:37:11 +03:00
|
|
|
REGISTER_XSPICE_1 (XspiceGeneric);
|
2023-05-29 16:42:57 +03:00
|
|
|
//REGISTER_XSPICE_1 (XSP_CMlib);
|
|
|
|
//REGISTER_XSPICE_1 (XSP_CodeModel);
|
2016-01-21 10:27:43 +03:00
|
|
|
|
2016-01-09 14:36:32 +03:00
|
|
|
// specific sections of spice netlists
|
|
|
|
REGISTER_SPICE_SEC_1 (SpiceParam);
|
2024-12-14 13:26:36 +03:00
|
|
|
REGISTER_SPICE_SEC_1 (SpiceCSParam);
|
2016-01-09 14:36:32 +03:00
|
|
|
REGISTER_SPICE_SEC_1 (SpiceGlobalParam);
|
|
|
|
REGISTER_SPICE_SEC_1 (SpiceOptions);
|
|
|
|
REGISTER_SPICE_SEC_1 (SpiceIC);
|
|
|
|
REGISTER_SPICE_SEC_1 (SpiceNodeset);
|
|
|
|
REGISTER_SPICE_SEC_1 (NutmegEquation);
|
|
|
|
REGISTER_SPICE_SEC_1 (S4Q_Model);
|
|
|
|
REGISTER_SPICE_SEC_1 (S4Q_Include);
|
2023-03-10 19:49:42 +03:00
|
|
|
REGISTER_SPICE_SEC_1 (S4Q_Lib);
|
2017-03-03 14:19:31 +03:00
|
|
|
REGISTER_SPICE_SEC_1 (SpiceFunc);
|
2019-06-21 13:09:59 -04:00
|
|
|
REGISTER_SPICE_SEC_1 (SpiceSpiceinit);
|
2017-03-03 16:09:51 +03:00
|
|
|
REGISTER_SPICE_SEC_1 (InclScript);
|
|
|
|
|
2016-01-09 14:36:32 +03:00
|
|
|
|
|
|
|
// Qucs legacy devices
|
2023-06-09 13:54:29 +03:00
|
|
|
// REGISTER_QUCS_2 (Resistor, info, info_us);
|
|
|
|
// REGISTER_QUCS_1 (Capacitor);
|
|
|
|
// REGISTER_QUCS_1 (Inductor);
|
|
|
|
// REGISTER_QUCS_1 (Diode);
|
|
|
|
// REGISTER_QUCS_2 (BJT, info, info_pnp);
|
|
|
|
// REGISTER_QUCS_2 (BJTsub, info, info_pnp);
|
|
|
|
// REGISTER_QUCS_2 (JFET, info, info_p);
|
|
|
|
// REGISTER_QUCS_3 (MOSFET, info, info_p, info_depl);
|
|
|
|
// REGISTER_QUCS_3 (MOSFET_sub, info, info_p, info_depl);
|
|
|
|
//}
|
2015-02-24 15:43:38 +03:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
// paintings
|
|
|
|
REGISTER_PAINT_1 (GraphicLine);
|
|
|
|
REGISTER_PAINT_1 (Arrow);
|
|
|
|
REGISTER_PAINT_1 (GraphicText);
|
2022-02-20 16:25:39 +01:00
|
|
|
REGISTER_PAINT_2 (qucs::Ellipse, info, info_filled);
|
|
|
|
REGISTER_PAINT_2 (qucs::Rectangle, info, info_filled);
|
2009-11-08 16:33:19 +00:00
|
|
|
REGISTER_PAINT_1 (EllipseArc);
|
2014-01-10 13:29:56 +00:00
|
|
|
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This function has to be called once at application end. It removes
|
|
|
|
// all categories and registered modules from memory.
|
2024-09-24 00:25:48 +03:00
|
|
|
void Module::unregisterModules(void) {
|
|
|
|
while (!Category::Categories.isEmpty()) {
|
2014-11-05 23:49:38 +08:00
|
|
|
delete Category::Categories.takeFirst();
|
|
|
|
}
|
2014-11-03 04:01:47 +08:00
|
|
|
|
2024-09-24 00:25:48 +03:00
|
|
|
QHash<QString, Module*>::iterator i = Modules.begin();
|
|
|
|
while (i != Modules.end()) {
|
|
|
|
if (i.value() == 0) { // test here
|
|
|
|
delete i.value();
|
|
|
|
i = Modules.erase(i);
|
|
|
|
} else {
|
|
|
|
++i;
|
2023-06-09 13:54:29 +03:00
|
|
|
}
|
2024-09-24 00:25:48 +03:00
|
|
|
}
|
|
|
|
Modules.clear();
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Constructor creates instance of module object.
|
|
|
|
Category::Category () {
|
|
|
|
Name = "#special";
|
2014-11-06 00:29:04 +08:00
|
|
|
while(!Content.isEmpty()) {
|
|
|
|
delete Content.takeFirst();
|
|
|
|
}
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Constructor creates named instance of module object.
|
|
|
|
Category::Category (const QString name) {
|
|
|
|
Name = name;
|
2014-11-06 00:29:04 +08:00
|
|
|
while(!Content.isEmpty()) {
|
|
|
|
delete Content.takeFirst();
|
|
|
|
}
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Destructor removes instance of module object from memory.
|
|
|
|
Category::~Category () {
|
2014-11-06 00:29:04 +08:00
|
|
|
while(!Content.isEmpty()) {
|
|
|
|
delete Content.takeFirst();
|
|
|
|
}
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the available category names in a list of strings.
|
|
|
|
QStringList Category::getCategories (void) {
|
|
|
|
QStringList res;
|
2014-11-05 23:49:38 +08:00
|
|
|
QList<Category *>::const_iterator it;
|
|
|
|
for (it = Category::Categories.constBegin();
|
|
|
|
it != Category::Categories.constEnd(); it++) {
|
|
|
|
res.append ((*it)->Name);
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The function returns the registered modules in the given category
|
|
|
|
// as a pointer list. The pointer list is empty if there is no such
|
|
|
|
// category available.
|
2014-11-06 00:29:04 +08:00
|
|
|
QList<Module *> Category::getModules (QString category) {
|
|
|
|
QList<Module *> res;
|
2014-11-05 23:49:38 +08:00
|
|
|
QList<Category *>::const_iterator it;
|
|
|
|
for (it = Category::Categories.constBegin();
|
|
|
|
it != Category::Categories.constEnd(); it++) {
|
2014-11-06 00:29:04 +08:00
|
|
|
if (category == (*it)->Name) {
|
2014-11-05 23:49:38 +08:00
|
|
|
res = (*it)->Content;
|
2014-11-06 00:29:04 +08:00
|
|
|
}
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the index number into the category list for the given
|
2014-11-05 23:49:38 +08:00
|
|
|
// category name. The function returns minus 1 if there is no such
|
2009-11-08 16:33:19 +00:00
|
|
|
// category.
|
|
|
|
int Category::getModulesNr (QString category) {
|
2014-11-05 23:49:38 +08:00
|
|
|
for (int i = 0; i < Category::Categories.size(); i++) {
|
|
|
|
if (category == Category::Categories.at(i)->Name)
|
2009-11-08 16:33:19 +00:00
|
|
|
return i;
|
|
|
|
}
|
2014-11-05 23:49:38 +08:00
|
|
|
return -1;
|
2009-11-08 16:33:19 +00:00
|
|
|
}
|