Exemplo n.º 1
0
QucsFilter::QucsFilter()
{
    // set application icon
    setIcon (QPixmap(QucsSettings.BitmapDir + "big.qucs.xpm"));
    setCaption("Qucs Filter " PACKAGE_VERSION);


    // --------  create menubar  -------------------
    QPopupMenu *fileMenu = new QPopupMenu();
    fileMenu->insertItem(tr("E&xit"), this, SLOT(slotQuit()), CTRL+Key_Q);

    QPopupMenu *helpMenu = new QPopupMenu();
    helpMenu->insertItem(tr("Help..."), this, SLOT(slotHelpIntro()), Key_F1);
    helpMenu->insertSeparator();
    helpMenu->insertItem(
        tr("&About QucsFilter..."), this, SLOT(slotHelpAbout()), 0);
    helpMenu->insertItem(tr("About Qt..."), this, SLOT(slotHelpAboutQt()), 0);

    QMenuBar *bar = new QMenuBar(this);
    bar->insertItem(tr("&File"), fileMenu);
    bar->insertSeparator ();
    bar->insertItem(tr("&Help"), helpMenu);


    // -------  create main windows widgets --------
    gbox = new QGridLayout(this, 10,3,5,5);

    QWidget *Space = new QWidget(this);   // reserve space for menubar
    Space->setFixedSize(5, bar->height());
    gbox->addWidget(Space, 0,0);

    QLabel *Label1 = new QLabel(tr("Filter type:"), this);
    gbox->addWidget(Label1, 1,0);
    ComboType = new QComboBox(this);
    ComboType->insertItem("Bessel");
    ComboType->insertItem("Butterworth");
    ComboType->insertItem("Chebyshev");
    ComboType->insertItem("Cauer");
    gbox->addWidget(ComboType, 1,1);
    connect(ComboType, SIGNAL(activated(int)), SLOT(slotTypeChanged(int)));

    QLabel *Label2 = new QLabel(tr("Filter class:"), this);
    gbox->addWidget(Label2, 2,0);
    ComboClass = new QComboBox(this);
    ComboClass->insertItem(tr("Low pass"));
    ComboClass->insertItem(tr("High pass"));
    ComboClass->insertItem(tr("Band pass"));
    ComboClass->insertItem(tr("Band stop"));
    gbox->addWidget(ComboClass, 2,1);
    connect(ComboClass, SIGNAL(activated(int)), SLOT(slotClassChanged(int)));

    IntVal = new QIntValidator(1, 200, this);
    DoubleVal = new QDoubleValidator(this);

    LabelOrder = new QLabel(tr("Order:"), this);
    gbox->addWidget(LabelOrder, 3,0);
    EditOrder = new QLineEdit("3", this);
    EditOrder->setValidator(IntVal);
    gbox->addWidget(EditOrder, 3,1);

    LabelStart = new QLabel(tr("Corner frequency:"), this);
    gbox->addWidget(LabelStart, 4,0);
    EditCorner = new QLineEdit("1", this);
    EditCorner->setValidator(DoubleVal);
    gbox->addWidget(EditCorner, 4,1);
    ComboCorner = new QComboBox(this);
    ComboCorner->insertItem("Hz");
    ComboCorner->insertItem("kHz");
    ComboCorner->insertItem("MHz");
    ComboCorner->insertItem("GHz");
    ComboCorner->setCurrentItem(3);
    gbox->addWidget(ComboCorner, 4,2);

    LabelStop = new QLabel(tr("Stop frequency:"), this);
    gbox->addWidget(LabelStop, 5,0);
    EditStop = new QLineEdit("2", this);
    EditStop->setValidator(DoubleVal);
    gbox->addWidget(EditStop, 5,1);
    ComboStop = new QComboBox(this);
    ComboStop->insertItem("Hz");
    ComboStop->insertItem("kHz");
    ComboStop->insertItem("MHz");
    ComboStop->insertItem("GHz");
    ComboStop->setCurrentItem(3);
    gbox->addWidget(ComboStop, 5,2);

    LabelBandStop = new QLabel(tr("Stop band frequency:"), this);
    gbox->addWidget(LabelBandStop, 6,0);
    EditBandStop = new QLineEdit("3", this);
    EditBandStop->setValidator(DoubleVal);
    gbox->addWidget(EditBandStop, 6,1);
    ComboBandStop = new QComboBox(this);
    ComboBandStop->insertItem("Hz");
    ComboBandStop->insertItem("kHz");
    ComboBandStop->insertItem("MHz");
    ComboBandStop->insertItem("GHz");
    ComboBandStop->setCurrentItem(3);
    gbox->addWidget(ComboBandStop, 6,2);

    LabelRipple = new QLabel(tr("Pass band ripple:"), this);
    gbox->addWidget(LabelRipple, 7,0);
    EditRipple = new QLineEdit("1", this);
    EditRipple->setValidator(DoubleVal);
    gbox->addWidget(EditRipple, 7,1);
    LabelRipple_dB = new QLabel("dB", this);
    gbox->addWidget(LabelRipple_dB, 7,2);

    LabelAtten = new QLabel(tr("Stop band attenuation:"), this);
    gbox->addWidget(LabelAtten, 8,0);
    EditAtten = new QLineEdit("20", this);
    EditAtten->setValidator(DoubleVal);
    gbox->addWidget(EditAtten, 8,1);
    LabelAtten_dB = new QLabel("dB", this);
    gbox->addWidget(LabelAtten_dB, 8,2);

    QLabel *Label9 = new QLabel(tr("Impedance:"), this);
    gbox->addWidget(Label9, 9,0);
    EditImpedance = new QLineEdit("50", this);
    EditImpedance->setValidator(DoubleVal);
    gbox->addWidget(EditImpedance, 9,1);
    QLabel *Label10 = new QLabel("Ohm", this);
    gbox->addWidget(Label10, 9,2);


    QPushButton *ButtonGo =
        new QPushButton(tr("Calculate and put into Clipboard"), this);
    connect(ButtonGo, SIGNAL(clicked()), SLOT(slotCalculate()));
    gbox->addMultiCellWidget(ButtonGo, 10,10,0,2);

    LabelResult = new QLabel(this);
    ResultState = 100;
    slotShowResult();
    LabelResult->setAlignment(Qt::AlignHCenter);
    gbox->addMultiCellWidget(LabelResult, 11,11,0,2);


    // -------  finally set initial state  --------
    slotTypeChanged(0);
    slotClassChanged(0);
}
Exemplo n.º 2
0
QucsFilter::QucsFilter()
{
  QWidget *centralWidget = new QWidget(this);  
  setCentralWidget(centralWidget);
  
  // set application icon
  setWindowIcon(QPixmap(":/bitmaps/big.qucs.xpm"));
  setWindowTitle("Qucs Filter " PACKAGE_VERSION);

  // --------  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(slotQuit()));

  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);

  // -------  create main windows widgets --------
  all  = new QGridLayout();
  all->setSpacing(3);

  // ...........................................................
  box1 = new QGroupBox(tr("Filter"), this);
  QHBoxLayout *hbox = new QHBoxLayout();

  gbox1 = new QGridLayout();
  gbox1->setSpacing(3);

  box1->setLayout(gbox1);

  QLabel *Label0 = new QLabel(tr("Realization:"), this);
  gbox1->addWidget(Label0, 0,0);
  ComboRealize = new QComboBox(this);
  ComboRealize->addItem("LC ladder (pi type)");
  ComboRealize->addItem("LC ladder (tee type)");
  ComboRealize->addItem("End coupled transmission lines");
  ComboRealize->addItem("Parallel coupled transmission lines");
  ComboRealize->addItem("Stepped-impedance");
  ComboRealize->addItem("Quarter wave resonators");
  ComboRealize->addItem("Quarter wave side coupled ring resonator");
  ComboRealize->addItem("Capacitively coupled shunt resonators");
  ComboRealize->addItem("Equation-defined");

  gbox1->addWidget(ComboRealize, 0,1);
  connect(ComboRealize, SIGNAL(activated(int)), SLOT(slotRealizationChanged(int)));

   //Synthesize Microstrip
  MicrostripcheckBox=new QCheckBox("Microstrip implementation");
  MicrostripcheckBox->setChecked(false);
  MicrostripcheckBox->setEnabled(false);
  gbox1->addWidget(MicrostripcheckBox, 1,0);
  connect(MicrostripcheckBox, SIGNAL(clicked()), SLOT(on_MicrostripcheckBox_clicked()));

  QLabel *Label1 = new QLabel(tr("Filter type:"), this);
  gbox1->addWidget(Label1, 2,0);
  ComboType = new QComboBox(this);
  ComboType->addItem("Bessel");
  ComboType->addItem("Butterworth");
  ComboType->addItem("Chebyshev");
  ComboType->addItem("Cauer");
  gbox1->addWidget(ComboType, 2,1);
  connect(ComboType, SIGNAL(activated(int)), SLOT(slotTypeChanged(int)));

  QLabel *Label2 = new QLabel(tr("Filter class:"), this);
  gbox1->addWidget(Label2, 3,0);
  ComboClass = new QComboBox(this);
  ComboClass->addItem(tr("Low pass"));
  ComboClass->addItem(tr("High pass"));
  ComboClass->addItem(tr("Band pass"));
  ComboClass->addItem(tr("Band stop"));
  gbox1->addWidget(ComboClass, 3,1);
  connect(ComboClass, SIGNAL(activated(int)), SLOT(slotClassChanged(int)));

  IntVal = new QIntValidator(1, 200, this);
  DoubleVal = new QDoubleValidator(this);

  LabelOrder = new QLabel(tr("Order:"), this);
  gbox1->addWidget(LabelOrder, 4,0);
  EditOrder = new QLineEdit("3", this);
  EditOrder->setValidator(IntVal);
  gbox1->addWidget(EditOrder, 4,1);

  LabelStart = new QLabel(tr("Corner frequency:"), this);
  gbox1->addWidget(LabelStart, 5,0);
  EditCorner = new QLineEdit("1", this);
  EditCorner->setValidator(DoubleVal);
  gbox1->addWidget(EditCorner, 5,1);
  ComboCorner = new QComboBox(this);
  ComboCorner->addItem("Hz");
  ComboCorner->addItem("kHz");
  ComboCorner->addItem("MHz");
  ComboCorner->addItem("GHz");
  ComboCorner->setCurrentIndex(3);
  gbox1->addWidget(ComboCorner, 5,2);

  LabelStop = new QLabel(tr("Stop frequency:"), this);
  gbox1->addWidget(LabelStop, 6,0);
  EditStop = new QLineEdit("2", this);
  EditStop->setValidator(DoubleVal);
  gbox1->addWidget(EditStop, 6,1);
  ComboStop = new QComboBox(this);
  ComboStop->addItem("Hz");
  ComboStop->addItem("kHz");
  ComboStop->addItem("MHz");
  ComboStop->addItem("GHz");
  ComboStop->setCurrentIndex(3);
  gbox1->addWidget(ComboStop, 6,2);

  LabelBandStop = new QLabel(tr("Stop band frequency:"), this);
  gbox1->addWidget(LabelBandStop, 7,0);
  EditBandStop = new QLineEdit("3", this);
  EditBandStop->setValidator(DoubleVal);
  gbox1->addWidget(EditBandStop, 7,1);
  ComboBandStop = new QComboBox(this);
  ComboBandStop->addItem("Hz");
  ComboBandStop->addItem("kHz");
  ComboBandStop->addItem("MHz");
  ComboBandStop->addItem("GHz");
  ComboBandStop->setCurrentIndex(3);
  gbox1->addWidget(ComboBandStop, 7,2);

  LabelRipple = new QLabel(tr("Pass band ripple:"), this);
  gbox1->addWidget(LabelRipple, 8,0);
  EditRipple = new QLineEdit("1", this);
  EditRipple->setValidator(DoubleVal);
  gbox1->addWidget(EditRipple, 8,1);
  LabelRipple_dB = new QLabel("dB", this);
  gbox1->addWidget(LabelRipple_dB, 8,2);

  LabelAtten = new QLabel(tr("Stop band attenuation:"), this);
  gbox1->addWidget(LabelAtten, 9,0);
  EditAtten = new QLineEdit("20", this);
  EditAtten->setValidator(DoubleVal);
  gbox1->addWidget(EditAtten, 9,1);
  LabelAtten_dB = new QLabel("dB", this);
  gbox1->addWidget(LabelAtten_dB, 9,2);

  LabelImpedance = new QLabel(tr("Impedance:"), this);
  gbox1->addWidget(LabelImpedance, 10,0);
  EditImpedance = new QLineEdit("50", this);
  EditImpedance->setValidator(DoubleVal);
  gbox1->addWidget(EditImpedance, 10,1);
  LabelOhm = new QLabel("Ohm", this);
  gbox1->addWidget(LabelOhm, 10,2);

  // ...........................................................

  box2 = new QGroupBox(tr("Microstrip Substrate"), this);
  box2->setEnabled(false);

  gbox2 = new QGridLayout();
  gbox2->setSpacing(3);

  box2->setLayout(gbox2);

  QLabel *Label3 = new QLabel(tr("Relative permittivity:"), this);
  gbox2->addWidget(Label3, 0,0);
  ComboEr = new QComboBox(this);
  ComboEr->setEditable(true);
  ComboEr->lineEdit()->setValidator(DoubleVal);
  connect(ComboEr, SIGNAL(activated(const QString&)), SLOT(slotTakeEr(const QString&)));
  gbox2->addWidget(ComboEr, 0,1);

  const char **p = List_er;
  while(*(++p))
    ComboEr->addItem(*p);  // put material properties into combobox
  ComboEr->lineEdit()->setText("9.8");

  QLabel *Label4 = new QLabel(tr("Substrate height:"), this);
  gbox2->addWidget(Label4, 1,0);
  EditHeight = new QLineEdit("1.0", this);
  EditHeight->setValidator(DoubleVal);
  gbox2->addWidget(EditHeight, 1,1);
  QLabel *Label5 = new QLabel("mm", this);
  gbox2->addWidget(Label5, 1,2);

  QLabel *Label6 = new QLabel(tr("metal thickness:"), this);
  gbox2->addWidget(Label6, 2,0);
  EditThickness = new QLineEdit("12.5", this);
  EditThickness->setValidator(DoubleVal);
  gbox2->addWidget(EditThickness, 2,1);
  QLabel *Label7 = new QLabel("um", this);
  gbox2->addWidget(Label7, 2,2);

  QLabel *Label8 = new QLabel(tr("minimum width:"), this);
  gbox2->addWidget(Label8, 3,0);
  EditMinWidth = new QLineEdit("0.4", this);
  EditMinWidth->setValidator(DoubleVal);
  gbox2->addWidget(EditMinWidth, 3,1);
  QLabel *Label9 = new QLabel("mm", this);
  gbox2->addWidget(Label9, 3,2);

  QLabel *Label10 = new QLabel(tr("maximum width:"), this);
  gbox2->addWidget(Label10, 4,0);
  EditMaxWidth = new QLineEdit("5.0", this);
  EditMaxWidth->setValidator(DoubleVal);
  gbox2->addWidget(EditMaxWidth, 4,1);
  QLabel *Label11 = new QLabel("mm", this);
  gbox2->addWidget(Label11, 4,2);

  QSpacerItem *mySpacer=new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding);
  gbox2->addItem(mySpacer, 5, 0, 1, -1);

   QSize sz;
   boxImage = new QGroupBox(tr("Preview"), this);
   gboxImage = new QGridLayout();
   boxImage->setLayout(gboxImage);
   QString s1 = ":/bitmaps/LC_Ladder_Pi_LPF.svg";
   imgLayout = new QSvgWidget(s1);
   sz = imgLayout->size();
   imgLayout->setFixedSize(.5*sz);
   gboxImage->addWidget(imgLayout);
    
 

  // ...........................................................
  QVBoxLayout *vboxButtons = new QVBoxLayout();
  QPushButton *ButtonGo = new QPushButton(tr("Calculate and put into Clipboard"), this);
  connect(ButtonGo, SIGNAL(clicked()), SLOT(slotCalculate()));
  vboxButtons->addWidget(ButtonGo);

  LabelResult = new QLabel(this);
  ResultState = 100;
  slotShowResult();
  LabelResult->setAlignment(Qt::AlignHCenter);
  vboxButtons->addWidget(LabelResult);

  QVBoxLayout *vbox_all = new QVBoxLayout();
  QVBoxLayout *vboxRealisation = new QVBoxLayout();
  QVBoxLayout *vboxMicrostrip = new QVBoxLayout();

  vboxRealisation->addWidget(box1);
  hbox->addLayout(vboxRealisation);
  vboxMicrostrip->addWidget(box2);
  vboxMicrostrip->addWidget(boxImage);
  hbox->addLayout(vboxMicrostrip);
  vbox_all->addLayout(hbox);
  vbox_all->addLayout(vboxButtons);
  centralWidget->setLayout(vbox_all);

  // -------  finally set initial state  --------
  slotTypeChanged(0);
  slotClassChanged(0);
}
Exemplo n.º 3
0
ServiceCharges::ServiceCharges(MainWindow* main)
    : QuasarWindow(main, "ServiceCharges")
{
    _helpSource = "service_charges.html";

    QWidget* frame = new QWidget(this);

    QLabel* startLabel = new QLabel(tr("Start Date:"), frame);
    _start = new DatePopup(frame);
    startLabel->setBuddy(_start);

    QLabel* endLabel = new QLabel(tr("End Date:"), frame);
    _end = new DatePopup(frame);
    endLabel->setBuddy(_end);

    QLabel* storeLabel = new QLabel(tr("Store:"), frame);
    _store = new LookupEdit(new StoreLookup(_main, this), frame);
    _store->setFocusPolicy(ClickFocus);
    _store->setLength(20);
    storeLabel->setBuddy(_store);

    QLabel* accountLabel = new QLabel(tr("Account:"), frame);
    _account = new LookupEdit(new AccountLookup(_main, this), frame);
    _account->setFocusPolicy(ClickFocus);
    _account->setLength(20);
    accountLabel->setBuddy(_account);

    _charges = new ListView(frame);
    _charges->setAllColumnsShowFocus(true);
    _charges->setRootIsDecorated(false);
    _charges->setShowSortIndicator(true);
    _charges->addTextColumn(tr("Customer"), 50);
    _charges->addMoneyColumn(tr("Amount"));

    QFrame* buttons = new QFrame(frame);
    QPushButton* calc = new QPushButton(tr("Calculate"), buttons);
    QPushButton* post = new QPushButton(tr("Post"), buttons);
    QPushButton* cancel = new QPushButton(tr("Cancel"), buttons);
    connect(calc, SIGNAL(clicked()), this, SLOT(slotCalculate()));
    connect(post, SIGNAL(clicked()), this, SLOT(slotPost()));
    connect(cancel, SIGNAL(clicked()), this, SLOT(close()));

    QGridLayout* buttonGrid = new QGridLayout(buttons);
    buttonGrid->setSpacing(4);
    buttonGrid->setMargin(4);
    buttonGrid->setColStretch(0, 1);
    buttonGrid->addWidget(calc, 0, 1);
    buttonGrid->addWidget(post, 0, 2);
    buttonGrid->addWidget(cancel, 0, 3);

    QGridLayout* frameGrid = new QGridLayout(frame);
    frameGrid->setSpacing(6);
    frameGrid->setMargin(6);
    frameGrid->setRowStretch(2, 1);
    frameGrid->setColStretch(2, 1);
    frameGrid->addWidget(startLabel, 0, 0);
    frameGrid->addWidget(_start, 0, 1, AlignLeft | AlignVCenter);
    frameGrid->addWidget(storeLabel, 0, 3);
    frameGrid->addWidget(_store, 0, 4, AlignLeft | AlignVCenter);
    frameGrid->addWidget(endLabel, 1, 0);
    frameGrid->addWidget(_end, 1, 1, AlignLeft | AlignVCenter);
    frameGrid->addWidget(accountLabel, 1, 3);
    frameGrid->addWidget(_account, 1, 4, AlignLeft | AlignVCenter);
    frameGrid->addMultiCellWidget(_charges, 2, 2, 0, 4);
    frameGrid->addMultiCellWidget(buttons, 3, 3, 0, 4);

    Company company;
    _quasar->db()->lookup(company);

    if (company.lastServiceCharge().isNull()) {
	_start->setDate(QDate::currentDate() - 30);
	_end->setDate(QDate::currentDate());
    } else {
	_start->setDate(company.lastServiceCharge() + 1);
	_end->setDate(QDate::currentDate());
    }

    _store->setId(_quasar->defaultStore());
    _account->setId(company.chargeAccount());

    if (_quasar->storeCount() == 1) {
	storeLabel->hide();
	_store->hide();
    }

    if (_start->getDate().isNull()) {
	_start->setFocus();
    } else {
	_end->setFocus();
	_end->dateWidget()->selectAll();
    }

    setCentralWidget(frame);
    setCaption(tr("Service Charges"));
    finalize();
}