Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ra3xdh activefilter #14

Merged
merged 7 commits into from Jul 24, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions qucs/qucs-activefilter/CMakeLists.txt
Expand Up @@ -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})
Expand Down
7 changes: 4 additions & 3 deletions qucs/qucs-activefilter/Makefile.am
Expand Up @@ -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 $@ $<
Expand Down
7 changes: 1 addition & 6 deletions qucs/qucs-activefilter/filter.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
83 changes: 83 additions & 0 deletions qucs/qucs-activefilter/helpdialog.cpp
@@ -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 changes: 43 additions & 0 deletions qucs/qucs-activefilter/helpdialog.h
@@ -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 changes: 0 additions & 6 deletions qucs/qucs-activefilter/mfbfilter.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))));
Expand Down