Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Ra3xdh activefilter #14

Merged
merged 7 commits into from

2 participants

Vadim Kusnetsov Guilherme Brondani Torri
Vadim Kusnetsov
Owner

Dear Guilherme!

I made some changes according the last comment at PullRequest#13 and I would like to merge it into branch ra3xdh-activefilter. Changes are:

  1. All *.svg and *.png moved to bitmaps directory.
  2. Implemented automatic removing of Cauer filter topology, if Butterworth, Chebyshev or Bessel are selected. Now error message are not showed.
  3. Added QGroupBoxes and Interfaced optimized for laptops with 1366x768 resolution.
  4. I will add later some documentation in TeX format to qucs-doc directory. I think it is should describe underlying mathemathics of filter synthesis algorithms.

Here is screenshot of new interface with QGroupBoxes.

qucsactivefilter2

Vadim Kusnetsov ra3xdh referenced this pull request
Closed

Activefilt #13

Vadim Kusnetsov
Owner

I have added Help dialog and Main Menu bar similar to other Qucs-Tools. See last commit.

Guilherme Brondani Torri
Owner

There is an issue with your last commit:
https://travis-ci.org/Qucs/qucs/jobs/30621372#L3639

I guess you have to add helpdialog.cpp to the qucsactivefilter_SOURCES on the Makefile.am.

Vadim Kusnetsov
Owner

Issue is fixed. helpdialog.h and helpdialog.cpp are now added to Makefile.am. Travis CI builds OK.

Guilherme Brondani Torri guitorri merged commit 562a10a into from
Guilherme Brondani Torri
Owner

Should we rename the tool to QucsActiveFilter?

./qucsactivefilter.cpp:54:    QAction * helpAbout = new QAction(tr("&About QucsFilter..."), this);
./qucsactivefilter.cpp:533:    "QucsFilter Version " PACKAGE_VERSION+

What about band-pass and band-stop are these supported/implemented ?

Vadim Kusnetsov
Owner

Yes, it should be renamed. This issue is fixed by myself. See #16 for details.
Band stop and band pass filters are not implemented yet. There are only stubs for them. QucsActiveFilter shows warning when user tries to calculate these filters.
I had no time for this in June, because I had been receiving PhD degree in June. I am busy preparing articles for conferences now. I think to begin these functions implementation in September or October.
While this functions is not implemented, I can remove BandPass and BandStop from the cbxResponse QComboBox in the main window. Should I do it now?

Guilherme Brondani Torri guitorri added the enhancement label
Guilherme Brondani Torri
Owner

Will you have the time to continue implementing the missing filters?

Vadim Kusnetsov
Owner

Yes, I will continue BandPass/BandStop filters implementation this month.

Guilherme Brondani Torri guitorri referenced this pull request
Closed

Merge qucs-activefilter #43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  qucs/qucs-activefilter/CMakeLists.txt
View
@@ -47,12 +47,14 @@ qf_poly.cpp
sallenkey.cpp
schcauer.cpp
transferfuncdialog.cpp
+helpdialog.cpp
qucsactivefilter.cpp
)
SET(QUCS-ACTIVE-FILTER_MOC_HDRS
transferfuncdialog.h
qucsactivefilter.h
+helpdialog.h
)
QT4_WRAP_CPP(QUCS-ACTIVE-FILTER_MOC_SRCS ${QUCS-ACTIVE-FILTER_MOC_HDRS})
7 qucs/qucs-activefilter/Makefile.am
View
@@ -26,11 +26,12 @@ bin_PROGRAMS = qucsactivefilter
dist_man_MANS = qucsactivefilter.1
-MOCHEADERS = qucsactivefilter.h transferfuncdialog.h
+MOCHEADERS = qucsactivefilter.h transferfuncdialog.h helpdialog.h
MOCFILES = $(MOCHEADERS:.h=.moc.cpp)
-qucsactivefilter_SOURCES = main.cpp qucsactivefilter.cpp filter.cpp transferfuncdialog.cpp sallenkey.cpp \
- mfbfilter.cpp schcauer.cpp qf_poly.cpp qrc_qucsactivefilter.cpp
+qucsactivefilter_SOURCES = main.cpp qucsactivefilter.cpp filter.cpp helpdialog.cpp \
+transferfuncdialog.cpp sallenkey.cpp \
+mfbfilter.cpp schcauer.cpp qf_poly.cpp qrc_qucsactivefilter.cpp
qrc_qucsactivefilter.cpp: qucsactivefilter.qrc
$(RCC) -o $@ $<
0  qucs/qucs-activefilter/AFR.svg → qucs/qucs-activefilter/bitmaps/AFR.svg
View
File renamed without changes
0  qucs/qucs-activefilter/cauer.svg → qucs/qucs-activefilter/bitmaps/cauer.svg
View
File renamed without changes
0  qucs/qucs-activefilter/high-pass.svg → qucs/qucs-activefilter/bitmaps/high-pass.svg
View
File renamed without changes
0  qucs/qucs-activefilter/mfb-highpass.svg → qucs/qucs-activefilter/bitmaps/mfb-highpass.svg
View
File renamed without changes
0  qucs/qucs-activefilter/mfb-lowpass.svg → qucs/qucs-activefilter/bitmaps/mfb-lowpass.svg
View
File renamed without changes
0  qucs/qucs-activefilter/sk-highpass.svg → qucs/qucs-activefilter/bitmaps/sk-highpass.svg
View
File renamed without changes
0  qucs/qucs-activefilter/sk-lowpass.svg → qucs/qucs-activefilter/bitmaps/sk-lowpass.svg
View
File renamed without changes
0  qucs/qucs-activefilter/trfunc.png → qucs/qucs-activefilter/bitmaps/trfunc.png
View
File renamed without changes
7 qucs/qucs-activefilter/filter.cpp
View
@@ -53,11 +53,6 @@ void Filter::createSchematic(QString &s)
default: break;
}
- /*QFile sch("filter.sch");
- sch.open(QFile::WriteOnly);
- QTextStream out(&sch);
- out<<s;
- sch.close();*/
}
void Filter::createHighPassSchematic(QString &s)
@@ -156,7 +151,7 @@ void Filter::calcFirstOrder()
R1 = 1.0/(Wc*C*C1);
}
- qDebug()<<C;
+ //qDebug()<<C;
if (Kv != 1.0) {
R2 = Kv*R1/(Kv - 1);
83 qucs/qucs-activefilter/helpdialog.cpp
View
@@ -0,0 +1,83 @@
+/***************************************************************************
+ helpdialog.cpp
+ ------------------
+ begin : Fri Mar 04 2005
+ copyright : (C) 2005 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. *
+ * *
+ ***************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "helpdialog.h"
+
+
+#include <QPushButton>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QTextEdit>
+
+
+HelpDialog::HelpDialog(QWidget *parent)
+ : QDialog(parent) //, 0, false, Qt::WDestructiveClose)
+{
+ setWindowTitle("Qucs Filter Help");
+
+
+ // -------- set help text into dialog ------------
+ QString s(tr("QucsActiveFilter is a active filter synthesis program. "
+ "Butterworth, Chebyshev, Inverse Chebyshev, Cauer, Bessel"
+ " and User defined transfer function are supported."
+ "To create a filter, simply enter all "
+ "parameters and press the big button at the "
+ "bottom of the main window. Immediatly, the "
+ "schematic of the filter is calculated and "
+ "put into the clipboard. Now go to Qucs, "
+ "open an empty schematic and press "
+ "CTRL-V (paste from clipboard). The filter "
+ "schematic can now be inserted and "
+ " simulated. Have lots of fun!"));
+
+
+ // -------- create dialog widgets ------------
+ resize(250, 230);
+
+ vLayout = new QVBoxLayout();
+
+ Text = new QTextEdit(s, this);
+ //Text->setTextFormat(Qt::PlainText);
+ Text->setReadOnly(true);
+ //Text->setWordWrap(QTextEdit::NoWrap);
+ Text->setMinimumSize(200,200);
+ vLayout->addWidget(Text);
+
+ QVBoxLayout *h = new QVBoxLayout();
+ h->addLayout(vLayout);
+
+ h->addStretch(5);
+
+ QPushButton *ButtonClose = new QPushButton(tr("Close"));
+ h->addWidget(ButtonClose);
+ connect(ButtonClose, SIGNAL(clicked()), SLOT(accept()));
+ ButtonClose->setFocus();
+
+ h->addStretch(5);
+
+ setLayout(h);
+}
+
+HelpDialog::~HelpDialog()
+{
+ delete vLayout;
+}
+
43 qucs/qucs-activefilter/helpdialog.h
View
@@ -0,0 +1,43 @@
+/***************************************************************************
+ helpdialog.h
+ -------------------
+ begin : Fri Mar 04 2005
+ copyright : (C) 2005 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 HELPDIALOG_H
+#define HELPDIALOG_H
+
+#include <QDialog>
+#include <QVBoxLayout>
+#include <QTextEdit>
+
+class QTextEdit;
+class QVBoxLayout;
+
+/**
+ *@author Michael Margraf
+ */
+
+class HelpDialog : public QDialog {
+ Q_OBJECT
+public:
+ HelpDialog(QWidget *parent = 0);
+ ~HelpDialog();
+
+private:
+ QVBoxLayout *vLayout;
+ QTextEdit *Text;
+};
+
+#endif
6 qucs/qucs-activefilter/mfbfilter.cpp
View
@@ -63,7 +63,6 @@ void MFBfilter::createLowPassSchematic(QString &s)
s += QString("<GND * 1 %1 360 0 0 0 0>\n").arg(70+dx);
for (int i=1; i<=N2ord; i++) {
stage = Sections.at(i-1);
- qDebug()<<stage.N;
QString suffix1, suffix2;
float C1 = autoscaleCapacitor(stage.C1,suffix1);
float C2 = autoscaleCapacitor(stage.C2,suffix2);
@@ -138,7 +137,6 @@ void MFBfilter::createHighPassSchematic(QString &s)
s += QString("<GND * 1 %1 360 0 0 0 0>\n").arg(70+dx);
for (int i=1; i<=N2ord; i++) {
stage = Sections.at(i-1);
- qDebug()<<stage.N;
QString suffix1, suffix2;
float C1 = autoscaleCapacitor(stage.C1,suffix1);
float C2 = autoscaleCapacitor(stage.C2,suffix2);
@@ -206,8 +204,6 @@ void MFBfilter::calcHighPass()
float B = -2.0*re;
float C = re*re + im*im;
- qDebug()<<B<<C;
-
C1 = 10.0/Fc;
C2 = C1/Kv;
R1 = B/((2*C1+C2)*Wc);
@@ -240,8 +236,6 @@ void MFBfilter::calcLowPass()
float B = -2.0*re;
float C = re*re + im*im;
- qDebug()<<B<<C;
-
C2 = (10.0/Fc);
C1 = (B*B*C2)/(4*C*(Kv+1));
R2 = (2*(Kv+1))/(Wc*(B*C2+sqrt(B*B*C2*C2-4*C*C1*C2*(Kv+1))));
233 qucs/qucs-activefilter/qucsactivefilter.cpp
View
@@ -21,6 +21,10 @@
#include "mfbfilter.h"
#include "schcauer.h"
#include "transferfuncdialog.h"
+#include "helpdialog.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include <QTextCodec>
@@ -33,6 +37,37 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
+ // -------- create menubar -------------------
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction * fileQuit = new QAction(tr("E&xit"), this);
+ fileQuit->setShortcut(Qt::CTRL+Qt::Key_Q);
+ connect(fileQuit, SIGNAL(activated()), SLOT(close()));
+
+ fileMenu->addAction(fileQuit);
+
+ QMenu *helpMenu = new QMenu(tr("&Help"), this);
+ QAction * helpHelp = new QAction(tr("Help..."), this);
+ helpHelp->setShortcut(Qt::Key_F1);
+ connect(helpHelp, SIGNAL(activated()), SLOT(slotHelpIntro()));
+
+ QAction * helpAbout = new QAction(tr("&About QucsFilter..."), this);
+ helpMenu->addAction(helpAbout);
+ connect(helpAbout, SIGNAL(activated()), SLOT(slotHelpAbout()));
+
+ QAction * helpAboutQt = new QAction(tr("About Qt..."), this);
+ helpMenu->addAction(helpAboutQt);
+ connect(helpAboutQt, SIGNAL(activated()), SLOT(slotHelpAboutQt()));
+
+ helpMenu->addAction(helpHelp);
+ helpMenu->addSeparator();
+ helpMenu->addAction(helpAbout);
+ helpMenu->addAction(helpAboutQt);
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addSeparator();
+ menuBar()->addMenu(helpMenu);
+
//lblInputData = new QLabel(tr("Входные данные"));
lblA1 = new QLabel(tr("Passband attenuation, Ap (dB)"));
lblA2 = new QLabel(tr("Stopband attenuation, As (dB)"));
@@ -100,27 +135,28 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
cbxFilterType = new QComboBox;
QStringList lst;
- lst<<tr("Cauer section")
- <<tr("Multifeedback (MFB)")
- <<tr("Sallen-Key (S-K)");
+ lst<<tr("Multifeedback (MFB)")
+ <<tr("Sallen-Key (S-K)")
+ <<tr("Cauer section");
//<<tr("Пассивный");
cbxFilterType->addItems(lst);
connect(cbxFilterType,SIGNAL(currentIndexChanged(int)),this,SLOT(slotUpdateSchematic()));
this->slotSwitchParameters();
+ cbxFilterType->setMaxCount(3);
lblAFR = new QLabel(tr("General amplitude frequency response"));
lblTopology = new QLabel(tr("Filter topology preview (one stage)"));
- QString s1 = ":/images/AFR.svg";
+ QString s1 = ":/images/bitmaps/AFR.svg";
QSvgRenderer *ren = new QSvgRenderer(s1);
QSize sz = ren->defaultSize();
- sz *= 1.1;
+ sz *= 1.3;
delete ren;
imgAFR = new QSvgWidget(s1);
imgAFR->setFixedSize(sz);
imgAFR->show();
- s1 = ":/images/cauer.svg";
+ s1 = ":/images/bitmaps/cauer.svg";
ren = new QSvgRenderer(s1);
sz = ren->defaultSize();
sz *= 0.65;
@@ -129,50 +165,77 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
sch_pic = new QSvgWidget(s1);
sch_pic->setFixedSize(sz);
sch_pic->show();
+ this->slotUpdateSchematic();
top = new QHBoxLayout;
left = new QVBoxLayout;
center = new QVBoxLayout;
- right = new QVBoxLayout;
+ right = new QHBoxLayout;
//left->addWidget(lblInputData);
- left->addWidget(lblA1);
- left->addWidget(edtA1);
- left->addWidget(lblA2);
- left->addWidget(edtA2);
- left->addWidget(lblF1);
- left->addWidget(edtF1);
- left->addWidget(lblF2);
- left->addWidget(edtF2);
- left->addWidget(lblRpl1);
- left->addWidget(edtPassbRpl);
- left->addWidget(lblKv);
- left->addWidget(edtKv);
- left->addWidget(lblOrder);
- left->addWidget(edtOrder);
+ QGroupBox *gpbPar = new QGroupBox(tr("Filter parameters"));
+ QGridLayout *vl3 = new QGridLayout;
+ vl3->setSpacing(3);
+ vl3->addWidget(lblA1,0,0);
+ vl3->addWidget(edtA1,0,1);
+ vl3->addWidget(lblA2,1,0);
+ vl3->addWidget(edtA2,1,1);
+ vl3->addWidget(lblF1,2,0);
+ vl3->addWidget(edtF1,2,1);
+ vl3->addWidget(lblF2,3,0);
+ vl3->addWidget(edtF2,3,1);
+ vl3->addWidget(lblRpl1,4,0);
+ vl3->addWidget(edtPassbRpl,4,1);
+ vl3->addWidget(lblKv,5,0);
+ vl3->addWidget(edtKv,5,1);
+ vl3->addWidget(lblOrder,6,0);
+ vl3->addWidget(edtOrder,6,1);
+ left->addWidget(gpbPar);
+ gpbPar->setLayout(vl3);
+
+
+ QGroupBox *gpbFunc = new QGroupBox(tr("Transfer function and Topology"));
+ QVBoxLayout *vl4 = new QVBoxLayout;
+
QHBoxLayout *l3 = new QHBoxLayout;
l3->addWidget(lblTyp);
l3->addWidget(cbxFilterFunc);
- left->addLayout(l3);
+ vl4->addLayout(l3);
- left->addWidget(btnDefineTransferFunc);
+ vl4->addWidget(btnDefineTransferFunc);
QHBoxLayout *l1 = new QHBoxLayout;
l1->addWidget(lblResp);
l1->addWidget(cbxResponse);
- left->addLayout(l1);
+ vl4->addLayout(l1);
QHBoxLayout *l2 = new QHBoxLayout;
l2->addWidget(lblSch);
l2->addWidget(cbxFilterType);
- left->addLayout(l2);
- left->addWidget(btnCalcSchematic);
+ vl4->addLayout(l2);
+ vl4->addWidget(btnCalcSchematic);
+
+ gpbFunc->setLayout(vl4);
+ left->addWidget(gpbFunc);
+
left->addStretch();
- right->addWidget(lblAFR);
+ QGroupBox *gpbAFR = new QGroupBox(tr("General filter amplidure-frequency response"));
+ QVBoxLayout *vl1 = new QVBoxLayout;
+ vl1->addWidget(imgAFR);
+ gpbAFR->setLayout(vl1);
+ right->addWidget(gpbAFR);
+
+ QGroupBox *gpbSCH = new QGroupBox(tr("Filter topology preview"));
+ QVBoxLayout *vl2 = new QVBoxLayout;
+ vl2->addWidget(sch_pic);
+ gpbSCH->setLayout(vl2);
+ right->addWidget(gpbSCH);
+
+ /*right->addWidget(lblAFR);
right->addWidget(imgAFR);
right->addWidget(lblTopology);
right->addWidget(sch_pic);
- right->addStretch();
+ right->addStretch();*/
top->addLayout(left);
top->addLayout(center);
@@ -183,7 +246,13 @@ QucsActiveFilter::QucsActiveFilter(QWidget *parent)
QSplitter *sp1 = new QSplitter;
top1->addWidget(sp1);
txtResult->setReadOnly(true);
- top1->addWidget(txtResult);
+
+ QGroupBox *gpbCons = new QGroupBox(tr("Filter calculation console"));
+ QVBoxLayout *vl5 = new QVBoxLayout;
+ vl5->addWidget(txtResult);
+ gpbCons->setLayout(vl5);
+
+ top1->addWidget(gpbCons);
txtResult->setMinimumHeight(180);
zenter = new QWidget;
@@ -213,18 +282,18 @@ void QucsActiveFilter::slotCalcSchematic()
Filter::FilterFunc ffunc;
switch (cbxFilterFunc->currentIndex()) {
- case 0 : ffunc = Filter::Butterworth;
+ case funcButterworth : ffunc = Filter::Butterworth;
break;
- case 1 : ffunc = Filter::Chebyshev;
+ case funcChebyshev : ffunc = Filter::Chebyshev;
break;
- case 2 : ffunc = Filter::InvChebyshev;
+ case funcInvChebyshev : ffunc = Filter::InvChebyshev;
break;
- case 3 : ffunc = Filter::Cauer;
+ case funcCauer : ffunc = Filter::Cauer;
break;
- case 4 : ffunc = Filter::Bessel;
+ case funcBessel : ffunc = Filter::Bessel;
par.order = edtOrder->text().toInt();
break;
- case 5 : ffunc = Filter::User;
+ case funcUser : ffunc = Filter::User;
break;
default: ffunc = Filter::NoFunc;
break;
@@ -233,13 +302,13 @@ void QucsActiveFilter::slotCalcSchematic()
switch (cbxResponse->currentIndex()) {
- case 0 : ftyp = Filter::LowPass;
+ case tLowPass : ftyp = Filter::LowPass;
break;
- case 1 : ftyp = Filter::HighPass;
+ case tHiPass : ftyp = Filter::HighPass;
break;
- case 2 : ftyp = Filter::BandPass;
+ case tBandPass : ftyp = Filter::BandPass;
break;
- case 3 : ftyp = Filter::BandStop;
+ case tBandStop : ftyp = Filter::BandStop;
break;
default: ftyp = Filter::NoFilter;
break;
@@ -249,7 +318,7 @@ void QucsActiveFilter::slotCalcSchematic()
bool ok = false;
switch (cbxFilterType->currentIndex()) {
- case 0 : {
+ case topoCauer : {
if (((ffunc==Filter::InvChebyshev)||(ffunc==Filter::Cauer))) {
SchCauer cauer(ffunc,ftyp,par);
ok = cauer.calcFilter();
@@ -269,7 +338,7 @@ void QucsActiveFilter::slotCalcSchematic()
}
break;
- case 1 : {
+ case topoMFB : {
if (!((ffunc==Filter::InvChebyshev)||(ffunc==Filter::Cauer))) {
MFBfilter mfb(ffunc,ftyp,par);
if (ffunc==Filter::User) {
@@ -291,7 +360,7 @@ void QucsActiveFilter::slotCalcSchematic()
}
}
break;
- case 2 : {
+ case topoSallenKey : {
SallenKey sk(ffunc,ftyp,par);
if (ffunc==Filter::User) {
sk.set_TrFunc(coeffA,coeffB);
@@ -308,9 +377,8 @@ void QucsActiveFilter::slotCalcSchematic()
}
}
break;
- case 3 : errorMessage(tr("Function will be implemented in future version"));
+ default : errorMessage(tr("Function will be implemented in future version"));
break;
- default: break;
}
if (ok) {
@@ -326,19 +394,19 @@ void QucsActiveFilter::slotCalcSchematic()
void QucsActiveFilter::slotUpdateResponse()
{
- QString s = ":/images/AFR.svg";
+ QString s = ":/images/bitmaps/AFR.svg";
switch (cbxResponse->currentIndex()) {
- case 0 :
- s = ":/images/AFR.svg";
+ case tLowPass :
+ s = ":/images/bitmaps/AFR.svg";
ftyp = Filter::LowPass;
break;
- case 1 : s = ":/images/high-pass.svg";
+ case tHiPass : s = ":/images/bitmaps/high-pass.svg";
ftyp = Filter::HighPass;
break;
- case 2 : ftyp = Filter::BandPass;
+ case tBandPass : ftyp = Filter::BandPass;
break;
- case 3 : ftyp = Filter::BandStop;
+ case tBandStop : ftyp = Filter::BandStop;
break;
default: ftyp = Filter::NoFilter;
break;
@@ -358,21 +426,21 @@ void QucsActiveFilter::slotUpdateSchematic()
slotUpdateResponse();
QString s;
switch (cbxFilterType->currentIndex()) {
- case 0 : s = ":images/cauer.svg";
+ case topoCauer : s = ":images/bitmaps/cauer.svg"; // Cauer section
break;
- case 1 : if (ftyp==Filter::HighPass) {
- s = ":/images/mfb-highpass.svg";
+ case topoMFB : if (ftyp==Filter::HighPass) { // Multifeedback
+ s = ":/images/bitmaps/mfb-highpass.svg";
} else if (ftyp==Filter::LowPass) {
- s = ":/images/mfb-lowpass.svg";
+ s = ":/images/bitmaps/mfb-lowpass.svg";
}
break;
- case 2 : if (ftyp==Filter::HighPass) {
- s = ":/images/sk-highpass.svg";
+ case topoSallenKey : if (ftyp==Filter::HighPass) { // Sallen-Key
+ s = ":/images/bitmaps/sk-highpass.svg";
} else if (ftyp==Filter::LowPass) {
- s = ":/images/sk-lowpass.svg";
+ s = ":/images/bitmaps/sk-lowpass.svg";
}
break;
- case 3 : s = ":/images/mfb-lowpass.svg";
+ case 3 : s = ":/images/bitmaps/mfb-lowpass.svg";
break;
default:
break;
@@ -389,7 +457,7 @@ void QucsActiveFilter::slotUpdateSchematic()
void QucsActiveFilter::slotSwitchParameters()
{
- if (cbxFilterFunc->currentIndex()==0) {
+ if (cbxFilterFunc->currentIndex()==funcButterworth) { // Butterworth
edtA1->setEnabled(true);
edtPassbRpl->setEnabled(false);
} else {
@@ -397,20 +465,32 @@ void QucsActiveFilter::slotSwitchParameters()
edtPassbRpl->setEnabled(true);
}
- if ((cbxFilterFunc->currentIndex()==3)||(cbxFilterFunc->currentIndex()==2)) {
- cbxFilterType->setCurrentIndex(0);
+ if ((cbxFilterFunc->currentIndex()==funcCauer)||
+ (cbxFilterFunc->currentIndex()==funcInvChebyshev)) { // Inverse Chebyshev
+ // or Cauer
cbxFilterType->setDisabled(true);
} else {
cbxFilterType->setDisabled(false);
}
- if ((cbxFilterFunc->currentIndex())==4) {
+ if ((cbxFilterFunc->currentIndex()==funcInvChebyshev)|| // Inv.Chebyshev
+ (cbxFilterFunc->currentIndex()==funcCauer)|| // Cauer
+ (cbxFilterFunc->currentIndex()==funcUser)) // or User defined
+ {
+ cbxFilterType->addItem(tr("Cauer section"),Qt::DisplayRole);
+ cbxFilterType->setCurrentIndex(topoCauer);
+ } else {
+ cbxFilterType->removeItem(topoCauer);
+ }
+
+ if ((cbxFilterFunc->currentIndex())==funcBessel) { // Bessel
edtOrder->setEnabled(true);
} else {
edtOrder->setEnabled(false);
}
- if ((cbxFilterFunc->currentIndex()==5)||(cbxFilterFunc->currentIndex()==4)) {
+ if ((cbxFilterFunc->currentIndex()==funcUser)||
+ (cbxFilterFunc->currentIndex()==funcBessel)) { // Bessel or User Def.
btnDefineTransferFunc->setEnabled(true);
edtF2->setEnabled(false);
edtPassbRpl->setEnabled(false);
@@ -445,3 +525,30 @@ void QucsActiveFilter::errorMessage(QString str)
msg->exec();
delete msg;
}
+
+
+void QucsActiveFilter::slotHelpAbout()
+{
+ QMessageBox::about(this, tr("About..."),
+ "QucsFilter Version " PACKAGE_VERSION+
+ tr("\nActive Filter synthesis program\n")+
+ tr("Copyright (C) 2014 by")+
+ "\nVadim Kuznetsov\n"
+ "\nThis is free software; see the source for copying conditions."
+ "\nThere is NO warranty; not even for MERCHANTABILITY or "
+ "\nFITNESS FOR A PARTICULAR PURPOSE.\n\n");
+}
+
+// ************************************************************
+void QucsActiveFilter::slotHelpAboutQt()
+{
+ QMessageBox::aboutQt(this, tr("About Qt"));
+}
+
+// ************************************************************
+void QucsActiveFilter::slotHelpIntro()
+{
+ HelpDialog *d = new HelpDialog(this);
+ d->exec();
+ delete d;
+}
11 qucs/qucs-activefilter/qucsactivefilter.h
View
@@ -29,6 +29,12 @@ class QucsActiveFilter : public QMainWindow
Q_OBJECT
private:
+
+ enum lstTopology { topoMFB = 0, topoSallenKey = 1, topoCauer = 2};
+ enum lstFiltFunc { funcButterworth =0, funcChebyshev=1, funcInvChebyshev=2,
+ funcCauer = 3, funcBessel = 4, funcUser = 5};
+ enum lstFiltType { tLowPass =0, tHiPass=1, tBandPass=2, tBandStop=3};
+
QLabel *lblInputData;
QLabel *lblA1;
QLabel *lblA2;
@@ -77,7 +83,7 @@ class QucsActiveFilter : public QMainWindow
QHBoxLayout *top;
QVBoxLayout *left;
QVBoxLayout *center;
- QVBoxLayout *right;
+ QHBoxLayout *right;
QVBoxLayout *top1;
QSvgWidget *sch_pic;
@@ -103,6 +109,9 @@ private slots:
void slotCalcSchematic();
void slotSwitchParameters();
void slotDefineTransferFunc();
+ void slotHelpAbout();
+ void slotHelpAboutQt();
+ void slotHelpIntro();
public:
QucsActiveFilter(QWidget *parent = 0);
16 qucs/qucs-activefilter/qucsactivefilter.qrc
View
@@ -1,12 +1,12 @@
<RCC>
<qresource prefix="/images">
- <file>sk-highpass.svg</file>
- <file>sk-lowpass.svg</file>
- <file>mfb-lowpass.svg</file>
- <file>mfb-highpass.svg</file>
- <file>AFR.svg</file>
- <file>cauer.svg</file>
- <file>high-pass.svg</file>
- <file>trfunc.png</file>
+ <file>bitmaps/AFR.svg</file>
+ <file>bitmaps/cauer.svg</file>
+ <file>bitmaps/high-pass.svg</file>
+ <file>bitmaps/mfb-highpass.svg</file>
+ <file>bitmaps/mfb-lowpass.svg</file>
+ <file>bitmaps/sk-highpass.svg</file>
+ <file>bitmaps/sk-lowpass.svg</file>
+ <file>bitmaps/trfunc.png</file>
</qresource>
</RCC>
11 qucs/qucs-activefilter/sallenkey.cpp
View
@@ -37,7 +37,6 @@ void SallenKey::calcLowPass()
float Wc = 2*M_PI*Fc;
float Nst = order/2 + order%2;
float Kv1 = pow(Kv,1.0/Nst);
- qDebug()<<Kv1;
for (int k=1; k <= order/2; k++) {
@@ -46,9 +45,6 @@ void SallenKey::calcLowPass()
float B = -2.0*re;
float C = re*re + im*im;
- qDebug()<<B<<C;
-
-
C2 = 10 / Fc;
C1 = (B*B+4*C*(Kv1-1))*C2/(4*C);
R1 = 2/(Wc*(B*C2+sqrt((B*B + 4*C*(Kv1-1))*C2*C2-4*C*C1*C2)));
@@ -93,8 +89,6 @@ void SallenKey::calcHighPass()
float B = -2.0*re;
float C = re*re + im*im;
- qDebug()<<B<<C;
-
C1 = 10 / Fc;
R2 = 4*C/(Wc*C1*(B+sqrt(B*B+8*C*(Kv1-1))));
@@ -143,11 +137,9 @@ void SallenKey::createHighPassSchematic(QString &s)
s += QString("<GND * 1 %1 290 0 0 0 0>\n").arg(20+dx);
for (int i=1; i<=N2ord; i++) {
stage = Sections.at(i-1);
- qDebug()<<stage.N;
QString suffix1, suffix2;
float C1 = autoscaleCapacitor(stage.C1,suffix1);
float C2 = autoscaleCapacitor(stage.C2,suffix2);
- //qDebug()<<C1<<suffix1<<" "<<C2<<suffix2<<stage.C1<<stage.C2;
s += QString("<OpAmp OP%1 1 %2 160 -26 42 0 0 \"1e6\" 1 \"15 V\" 0>\n").arg(stage.N).arg(370+dx);
s += QString("<GND * 1 %1 270 0 0 0 0>\n").arg(270+dx);
s += QString("<GND * 1 %1 370 0 0 0 0>\n").arg(320+dx);
@@ -161,7 +153,6 @@ void SallenKey::createHighPassSchematic(QString &s)
}
if (N1stOrd!=0) {
- qDebug()<<Sections.last().N;
createFirstOrderComponentsHPF(s,Sections.last(),dx);
}
@@ -227,7 +218,7 @@ void SallenKey::createLowPassSchematic(QString &s)
s += QString("<GND * 1 %1 290 0 0 0 0>\n").arg(20+dx);
for (int i=1; i<=N2ord; i++) {
stage = Sections.at(i-1);
- qDebug()<<stage.N;
+ //qDebug()<<stage.N;
QString suffix1, suffix2;
float C1 = autoscaleCapacitor(stage.C1,suffix1);
float C2 = autoscaleCapacitor(stage.C2,suffix2);
5 qucs/qucs-activefilter/schcauer.cpp
View
@@ -45,8 +45,6 @@ void SchCauer::calcLowPass()
im = Zeros.at(k-1).imag();
float A = im*im;
- qDebug()<<A<<B<<C;
-
C1 = 10.0/Fc;
C2 = C1;
R5 = 1.0/(Wc*C1);
@@ -89,8 +87,6 @@ void SchCauer::calcHighPass()
im = Zeros.at(k-1).imag();
float A = im*im;
- qDebug()<<A<<B<<C;
-
C1 = 10.0/Fc;
C2 = C1;
R5 = 1.0/(Wc*C1);
@@ -145,7 +141,6 @@ void SchCauer::createGenericSchematic(QString &s)
for (int i=1; i<=N2ord; i++) {
stage = Sections.at(i-1);
- qDebug()<<stage.N;
QString suffix1, suffix2;
float C1 = autoscaleCapacitor(stage.C1,suffix1);
float C2 = autoscaleCapacitor(stage.C2,suffix2);
2  qucs/qucs-activefilter/transferfuncdialog.cpp
View
@@ -24,7 +24,7 @@ TransferFuncDialog::TransferFuncDialog(QVector<long double> &a, QVector<long dou
this->setWindowTitle(tr("Define filter transfer function"));
imgTrfuncEq = new QLabel;
- imgTrfuncEq->setPixmap(QPixmap(":images/trfunc.png"));
+ imgTrfuncEq->setPixmap(QPixmap(":images/bitmaps/trfunc.png"));
//imgTrfuncEq->setScaledContents(true);
Something went wrong with that request. Please try again.