Exemplo n.º 1
0
CentralWidget::CentralWidget(QWidget *parent) : QWidget(parent), timeOut(DEFAULT_TIMEOUT)
{

    watcher = new QFutureWatcher<QSharedPointer<PatternViewMap>>();
    compiler = new PatternCompiler();
    txt = new TextBasicWidget(this);
    pattern = new PatternsBasicWidget(compiler,this);
    matches = new MatchesBasicWidget(this);
    timeoutTimer = new QTimer(this);
    timeoutTimer->setSingleShot(true);
    QSplitter* vert = new QSplitter();
    QSplitter* horiz = new QSplitter();
    QWidget* containter = new QWidget();
    QHBoxLayout* containterLay = new QHBoxLayout();
    QVBoxLayout* mainLay = new QVBoxLayout();
    containterLay->setContentsMargins(0,0,0,0);
    horiz->addWidget(txt);
    horiz->addWidget(pattern);
    containterLay->addWidget(horiz);
    containter->setLayout(containterLay);
    vert->setOrientation(Qt::Vertical);
    vert->addWidget(containter);
    vert->addWidget(matches);

//    vert->addWidget(progress);
    mainLay->addWidget(vert);
    setLayout(mainLay);
    connect(pattern,SIGNAL(matchClicked()), this,SLOT(slotAnalyze()));
    connect(matches,SIGNAL(patternWasUnchecked(QString)),txt,SLOT(slotPatternUncheked(QString)));
    connect(matches,SIGNAL(patternWasChecked(QString)),txt,SLOT(slotPatternChecked(QString)));
    connect(matches,SIGNAL(showAll()),txt,SLOT(slotHighlightAll()));
    connect(matches,SIGNAL(showAll()),pattern,SLOT(slotDisableMatch()));
    connect(matches,SIGNAL(hideAll()),txt,SLOT(slotDehighlightAll()));
    connect(matches,SIGNAL(rowClicked(int,int)),txt,SLOT(slotSelectFragment(int,int)));
    connect(matches,SIGNAL(patternWasUnchecked(QString)),this,SIGNAL(statusHighlighting()));
    connect(matches,SIGNAL(patternWasChecked(QString)),this,SIGNAL(statusHighlighting()));

    connect(txt,SIGNAL(tabChanged(int)),matches,SLOT(slotChangeTab(int)));
    connect(txt,SIGNAL(tabClosed(int)),matches,SLOT(slotCloseTab(int)));
    connect(txt,SIGNAL(editEnabled()),matches,SLOT(slotClear()));
    connect(txt,SIGNAL(editEnabled()),this,SLOT(slotEdit()));
    connect(txt,SIGNAL(checkingEnabled()),matches,SLOT(slotEnableChecking()));
    connect(txt,SIGNAL(checkingEnabled()),this,SIGNAL(statusReady()));
    connect(txt, SIGNAL(checkingEnabled()),pattern, SLOT(slotEnableMatch()));

    connect(watcher,SIGNAL(finished()),this,SLOT(slotDisplay()));
    connect(timeoutTimer,SIGNAL(timeout()),this,SLOT(slotTimeout()));

    //connect(watcher,SIGNAL(progressValueChanged(int)),this,SLOT(slotProgress(int)));
    if (QFile::exists(CRASH_TEXT) && QFile::exists(CRASH_PATTERNS)){
        loadAfterCrash(CRASH_TEXT, CRASH_PATTERNS);
    }
}
Exemplo n.º 2
0
/* Switches to the current type of transmission line layout. */
void QucsTranscalc::setMode (int _mode) {
  // change necessary?
  if (mode == _mode) return;
  storeValues ();
  mode = _mode;
  setUpdatesEnabled(false);
  updateMode ();

  // update selection and results
  updateSelection ();
  updateResultItems ();

  slotAnalyze();
  setUpdatesEnabled(true);
  repaint();
}
Exemplo n.º 3
0
/* Constructor setups the GUI. */
QucsTranscalc::QucsTranscalc() {
    
  QWidget *centralWidget = new QWidget(this);  
  setCentralWidget(centralWidget);
  
  // set application icon
  setWindowIcon(QPixmap(":/bitmaps/big.qucs.xpm"));
  setWindowTitle("Qucs Transcalc " PACKAGE_VERSION);

  // create file menu
  QMenu *fileMenu = new QMenu(tr("&File"));

  QAction *fileLoad = new QAction(tr("&Load"), this);
  fileLoad->setShortcut(Qt::CTRL+Qt::Key_L);
  fileMenu->addAction(fileLoad);
  connect(fileLoad, SIGNAL(activated()), SLOT(slotFileLoad()));

  QAction *fileSave = new QAction (tr("&Save"), this);
  fileSave->setShortcut(Qt::CTRL+Qt::Key_S);
  fileMenu->addAction(fileSave);
  connect(fileSave, SIGNAL(activated()), SLOT(slotFileSave()));

  fileMenu->addSeparator();

  QAction *fileOption = new QAction (tr("&Options"), this);
  fileOption->setShortcut(Qt::CTRL+Qt::Key_O);
  fileMenu->addAction(fileOption);
  connect(fileOption, SIGNAL(activated()), SLOT(slotOptions()));

  fileMenu->addSeparator();

  QAction *fileQuit = new QAction (tr("&Quit"), this);
  fileQuit->setShortcut(Qt::CTRL+Qt::Key_Q);
  fileMenu->addAction(fileQuit);
  connect(fileQuit, SIGNAL(activated()), SLOT(slotQuit()));

  // create execute menu
  QMenu *execMenu = new QMenu(tr("&Execute"));

  QAction *execCopy = new QAction(tr("&Copy to Clipboard"), this);
  execCopy->setShortcut(Qt::Key_F2);
  execMenu->addAction(execCopy);
  connect(execCopy, SIGNAL(activated()), SLOT(slotCopyToClipBoard()));

  QAction *execAnalyze = new QAction(tr("&Analyze"), this);
  execAnalyze->setShortcut(Qt::Key_F3);
  execMenu->addAction(execAnalyze);
  connect(execAnalyze, SIGNAL(activated()), SLOT(slotAnalyze()));

  QAction *execSynthesize = new QAction (tr("&Synthesize"), this);
  execSynthesize->setShortcut(Qt::Key_F4);
  execMenu->addAction(execSynthesize);
  connect(execSynthesize, SIGNAL(activated()), SLOT(slotSynthesize()));

  // create help menu
  QMenu *helpMenu = new QMenu(tr("&Help"));
  QAction *helpHelp = new QAction(tr("&Help"), this);
  helpHelp->setShortcut(Qt::Key_F1);
  helpMenu->addAction(helpHelp);
  connect(helpHelp, SIGNAL(activated()), SLOT(slotHelpIntro()));

  QAction *helpAbout = new QAction(tr("About"), this);
  helpMenu->addAction(helpAbout);
  connect(helpAbout, SIGNAL(activated()), SLOT(slotAbout()));

  // setup menu bar
  menuBar()->addMenu(fileMenu);
  menuBar()->addMenu(execMenu);
  menuBar()->addSeparator();
  menuBar()->addMenu(helpMenu);

  // === left
  // seletion combo and figure
  QVBoxLayout *vl = new QVBoxLayout();

  // transmission line type choice
  QGroupBox * lineGroup = new QGroupBox (tr("Transmission Line Type"));
  tranType = new QComboBox (lineGroup);
  tranType->insertItem (0, tr("Microstrip Line"));
  tranType->insertItem (1, tr("Coplanar Waveguide"));
  tranType->insertItem (2, tr("Grounded Coplanar"));
  tranType->insertItem (3, tr("Rectangular Waveguide"));
  tranType->insertItem (4, tr("Coaxial Line"));
  tranType->insertItem (5, tr("Coupled Microstrip"));
  connect(tranType, SIGNAL(activated(int)), SLOT(slotSelectType(int)));
  // setup transmission line picture
  pix = new QLabel (lineGroup);
  pix->setPixmap(QPixmap(":/bitmaps/microstrip.png"));

  QVBoxLayout *vfig = new QVBoxLayout();
  vfig->addWidget(tranType);
  vfig->addWidget(pix);
  vfig->setSpacing(3);
  lineGroup->setLayout(vfig);

  vl->addWidget(lineGroup);

  // init additional translations
  setupTranslations ();

  // set current mode
  mode = ModeMicrostrip;

  // === middle
  QVBoxLayout *vm = new QVBoxLayout();
  vm->setSpacing (3);

  // substrate parameter box
  QGroupBox * substrate = new QGroupBox (tr("Substrate Parameters"));
  vm->addWidget(substrate);

  // Pass the GroupBox > create Grid layout > Add widgets > set layout
  createPropItems (substrate, TRANS_SUBSTRATE);

  // component parameter box
  QGroupBox * component = new QGroupBox (tr("Component Parameters"));
  vm->addWidget(component);
  createPropItems (component, TRANS_COMPONENT);


  // === right
  QVBoxLayout *vr = new QVBoxLayout();
  vr->setSpacing (3);

  // physical parameter box
  QGroupBox * physical = new QGroupBox (tr("Physical Parameters"));
  vr->addWidget(physical);
  createPropItems (physical, TRANS_PHYSICAL);

  // analyze/synthesize buttons
  QHBoxLayout * h2 = new QHBoxLayout();
  QPushButton * analyze = new QPushButton (tr("Analyze"));
  h2->addWidget(analyze);
  analyze->setToolTip(tr("Derive Electrical Parameters"));
  connect(analyze, SIGNAL(clicked()), SLOT(slotAnalyze()));

  QPushButton * synthesize = new QPushButton (tr("Synthesize"));
  h2->addWidget(synthesize);
  synthesize->setToolTip(tr("Compute Physical Parameters"));
  connect(synthesize, SIGNAL(clicked()), SLOT(slotSynthesize()));
  vr->addLayout(h2);

  // electrical parameter box
  QGroupBox * electrical = new QGroupBox (tr("Electrical Parameters"));
  vr->addWidget(electrical);
  createPropItems (electrical, TRANS_ELECTRICAL);

  calculated = new QGroupBox (tr("Calculated Results"));
  vr->addWidget(calculated);

  // status line
  //statBar = new QStatusBar (this);
  //QLabel * statText = new QLabel ("Ready.", statBar);
  statusBar()->showMessage (tr("Ready."));
  //statBar->setFixedHeight (statText->height ());
  //delete statText;

  QVBoxLayout *vmain = new QVBoxLayout();

  QHBoxLayout *hmain = new QHBoxLayout();
  hmain->addLayout(vl);
  hmain->addLayout(vm);
  hmain->addLayout(vr);

  vmain->addLayout(hmain);
  //vmain->addWidget(statBar);
  
  centralWidget->setLayout(vmain);
  
  // setup calculated result bix
  createResultItems (calculated);
  updateSelection ();

  // instantiate transmission lines
  TransLineTypes[0].line = new microstrip ();
  TransLineTypes[0].line->setApplication (this);
  TransLineTypes[1].line = new coplanar ();
  TransLineTypes[1].line->setApplication (this);
  TransLineTypes[2].line = new groundedCoplanar ();
  TransLineTypes[2].line->setApplication (this);
  TransLineTypes[3].line = new rectwaveguide ();
  TransLineTypes[3].line->setApplication (this);
  TransLineTypes[4].line = new coax ();
  TransLineTypes[4].line->setApplication (this);
  TransLineTypes[5].line = new c_microstrip ();
  TransLineTypes[5].line->setApplication (this);
}