Exemplo n.º 1
0
void CQTSSAResultSubWidget::saveDataToFile()
{
  C_INT32 Answer = QMessageBox::No;
  QString fileName;

  while (Answer == QMessageBox::No)
    {
      fileName =
        CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
                                          "untitled.txt", "Text Files (*.txt)", "Save to");

      if (fileName.isEmpty()) return;

      // Checks whether the file exists
      Answer = checkSelection(fileName);

      if (Answer == QMessageBox::Cancel) return;
    }

  std::ofstream file(CLocaleString::fromUtf8(TO_UTF8(fileName)).c_str());

  if (file.fail()) return;

  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiTask* mpTask =
    dynamic_cast<CTSSATask *>((*(*CCopasiRootContainer::getDatamodelList())[0]->getTaskList())["Time Scale Separation Analysis"]);

  if (!mpTask) return;

  CCopasiProblem* mpProblem = mpTask->getProblem();

  mpProblem->printResult(&file);

  return;
}
Exemplo n.º 2
0
void CQLyapResultWidget::saveToFile()
{
  C_INT32 Answer = QMessageBox::No;
  QString fileName;

  while (Answer == QMessageBox::No)
    {
      fileName =
        CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
                                          "untitled.txt", "TEXT Files (*.txt)", "Save to");

      if (fileName.isEmpty()) return;

      // Checks whether the file exists
      Answer = checkSelection(fileName);

      if (Answer == QMessageBox::Cancel) return;
    }

  std::ofstream file(CLocaleString::fromUtf8(TO_UTF8(fileName)).c_str());

  if (file.fail())
    return;

  if (mpTask != NULL)
    mpTask->printResult(&file);

  return;
}
Exemplo n.º 3
0
void KeyListPresenter::deleteKey() {
	BOOST_LOG_NAMED_SCOPE("KeyListPresenter::deleteKey");
	if(checkSelection()) {
		KeyManager& myKeyMan(getFactory().getKeyManager());
		getYubikoOtpKeyPresenter().deleteKey(myKeyMan.getKey(itsSelectedKey));
	}
}
Exemplo n.º 4
0
void PlotWindow::slotSaveData()
{
  C_INT32 Answer = QMessageBox::No;
  QString fileName;

  while (Answer == QMessageBox::No)
    {
      fileName =
        CopasiFileDialog::getSaveFileName(this, "Save File Dialog", "untitled.txt", "TEXT Files (*.txt)", "Save Plot Data to");

      if (fileName.isNull()) return;

      // Checks whether the file exists
      Answer = checkSelection(fileName);

      if (Answer == QMessageBox::Cancel) return;
    }

  bool success = false;

  if (mpPlot)
    {
      QCursor oldCursor = cursor();
      setCursor(Qt::WaitCursor);
      success = mpPlot->saveData(TO_UTF8(fileName));
      setCursor(oldCursor);
    }

  if (!success)
    {
      std::string s = "Could not save data to ";
      s += TO_UTF8(fileName);
      CQMessageBox::critical(this, "Save Error", FROM_UTF8(s), QMessageBox::Ok, QMessageBox::NoButton);
    }
}
Exemplo n.º 5
0
  void CETranslateWidget::updateVector()
  {
    // Check translation mode
    switch (static_cast<TranslateMode>
            (ui.combo_translateMode->currentIndex())) {

    // Translating by an arbitrary vector
    case TM_VECTOR:
      // Disable selection monitor
      m_selectionTimer.stop();

      // Reenable editing of vector
      enableVectorEditor();

      // Clear any lingering errors
      clearError();

      // Pull out the coordinates
      m_vector.x() = ui.spin_x->value();
      m_vector.y() = ui.spin_y->value();
      m_vector.z() = ui.spin_z->value();
      break;

    // If moving an atom the origin, check for a single selected atom
    case TM_ATOM:
      // Start selection monitor
      m_selectionTimer.start(500);

      // Disable editing of vector
      disableVectorEditor();

      checkSelection();
      break;
    }
  }
Exemplo n.º 6
0
//============================================================================================================
CmdPromptInput::CmdPromptInput(QWidget* parent) : QLineEdit(parent)
{
    qDebug("CmdPromptInput Constructor");
    setObjectName("Command Prompt Input");

    prefix = "Command: ";
    curText = prefix;

    lastCmd = "help";
    curCmd = "help";
    cmdActive = false;

    rapidFireEnabled = false;

    this->setText(prefix);
    this->setFrame(false);
    this->setMaxLength(266);
    this->setMaximumSize(5000, 25);
    this->setDragEnabled(false);

    connect(this, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(checkCursorPosition(int, int)));
    connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(checkEditedText(const QString&)));
    connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(checkChangedText(const QString&)));
    connect(this, SIGNAL(selectionChanged()), this, SLOT(checkSelection()));

    aliasHash = new QHash<QString, QString>;

    this->installEventFilter(this);
    this->setFocus(Qt::OtherFocusReason);
}
Exemplo n.º 7
0
  CETranslateWidget::CETranslateWidget(CrystallographyExtension *ext)
    : CEAbstractDockWidget(ext),
      m_vector(0,0,0),
      m_gl(NULL)
  {
    ui.setupUi(this);

    connect(ui.combo_translateMode, SIGNAL(currentIndexChanged(int)),
            this, SLOT(updateVector()));
    connect(ui.combo_units, SIGNAL(currentIndexChanged(int)),
            this, SLOT(updateVector()));
    connect(ui.spin_x, SIGNAL(valueChanged(double)),
            this, SLOT(updateVector()));
    connect(ui.spin_y, SIGNAL(valueChanged(double)),
            this, SLOT(updateVector()));
    connect(ui.spin_z, SIGNAL(valueChanged(double)),
            this, SLOT(updateVector()));

    connect(ui.push_go, SIGNAL(clicked()),
            this, SLOT(translate()));

    connect(&m_selectionTimer, SIGNAL(timeout()),
            this, SLOT(checkSelection()));

    connect(ui.combo_units, SIGNAL(currentIndexChanged(int)),
            this, SLOT(updateGui()));

    // Set error label to show red text
    ui.label_error->setStyleSheet("QLabel {color: red;}");
    ui.label_error->hide();

    readSettings();
  }
Exemplo n.º 8
0
void CMCAResultSubwidget::slotSave()
{
  C_INT32 Answer = QMessageBox::No;
  QString fileName;

  while (Answer == QMessageBox::No)
    {
      fileName =
        CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
                                          "untitled.txt", "TEXT Files (*.txt)", "Save to");

      if (fileName.isEmpty()) return;

      // Checks whether the file exists
      Answer = checkSelection(fileName);

      if (Answer == QMessageBox::Cancel) return;
    }

  std::ofstream file(CLocaleString::fromUtf8(TO_UTF8(fileName)).c_str());

  if (file.fail())
    return;

  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiTask* mpTask =
    dynamic_cast<CMCATask *>((*(*CCopasiRootContainer::getDatamodelList())[0]->getTaskList())["Metabolic Control Analysis"]);

  if (mpTask != NULL)
    file << mpTask->getResult();

//    mpTask->printResult(file);

  return;
}
Exemplo n.º 9
0
void Screen::displayCharacter(unsigned short c)
{
    // Note that VT100 does wrapping BEFORE putting the character.
    // This has impact on the assumption of valid cursor positions.
    // We indicate the fact that a newline has to be triggered by
    // putting the cursor one right to the last column of the screen.

    int w = konsole_wcwidth(c);
    if (w <= 0)
        return;

    if (cuX+w > columns) {
        if (getMode(MODE_Wrap)) {
            lineProperties[cuY] = (LineProperty)(lineProperties[cuY] | LINE_WRAPPED);
            nextLine();
        }
        else
            cuX = columns-w;
    }

    // ensure current line vector has enough elements
    int size = screenLines[cuY].size();
    if (size < cuX+w)
    {
        screenLines[cuY].resize(cuX+w);
    }

    if (getMode(MODE_Insert)) insertChars(w);

    lastPos = loc(cuX,cuY);

    // check if selection is still valid.
    checkSelection(lastPos, lastPos);

    Character& currentChar = screenLines[cuY][cuX];

    currentChar.character = c;
    currentChar.foregroundColor = effectiveForeground;
    currentChar.backgroundColor = effectiveBackground;
    currentChar.rendition = effectiveRendition;

    int i = 0;
    int newCursorX = cuX + w--;
    while(w)
    {
        i++;

        if ( screenLines[cuY].size() < cuX + i + 1 )
            screenLines[cuY].resize(cuX+i+1);

        Character& ch = screenLines[cuY][cuX + i];
        ch.character = 0;
        ch.foregroundColor = effectiveForeground;
        ch.backgroundColor = effectiveBackground;
        ch.rendition = effectiveRendition;

        w--;
    }
    cuX = newCursorX;
}
Exemplo n.º 10
0
void CQDifferentialEquations::slotSave()
{
  QString outfilename;

  C_INT32 Answer = QMessageBox::No;

  while (Answer == QMessageBox::No)
    {
      outfilename =
        CopasiFileDialog::getSaveFileName(this,
                                          "Save File Dialog",
                                          "untitled.mml",
                                          "MathML (*.mml);;TeX (*.tex)",
                                          "Save Formula to Disk", new QString);

      if (outfilename.isEmpty()) return;

      // Checks whether the file exists
      Answer = checkSelection(outfilename);

      if (Answer == QMessageBox::Cancel)
        return;
    }

#ifdef DEBUG_UI
  qDebug() << "outfilename = " << outfilename;
#endif

  if (outfilename.contains(".tex"))
    saveTeX(outfilename);
  else
    saveMML(outfilename);
}
Exemplo n.º 11
0
QgsAuthAuthoritiesEditor::QgsAuthAuthoritiesEditor( QWidget *parent )
    : QWidget( parent )
    , mAuthNotifyLayout( nullptr )
    , mAuthNotify( nullptr )
    , mRootCaSecItem( nullptr )
    , mFileCaSecItem( nullptr )
    , mDbCaSecItem( nullptr )
    , mDefaultTrustPolicy( QgsAuthCertUtils::DefaultTrust )
    , mUtilitiesMenu( nullptr )
    , mDisabled( false )
    , mActionDefaultTrustPolicy( nullptr )
    , mActionShowTrustedCAs( nullptr )
{
  if ( QgsAuthManager::instance()->isDisabled() )
  {
    mDisabled = true;
    mAuthNotifyLayout = new QVBoxLayout;
    this->setLayout( mAuthNotifyLayout );
    mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
    mAuthNotifyLayout->addWidget( mAuthNotify );
  }
  else
  {
    setupUi( this );

    connect( QgsAuthManager::instance(), SIGNAL( messageOut( const QString&, const QString&, QgsAuthManager::MessageLevel ) ),
             this, SLOT( authMessageOut( const QString&, const QString&, QgsAuthManager::MessageLevel ) ) );

    connect( QgsAuthManager::instance(), SIGNAL( authDatabaseChanged() ),
             this, SLOT( refreshCaCertsView() ) );

    setupCaCertsTree();

    connect( treeWidgetCAs->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
             this, SLOT( selectionChanged( const QItemSelection&, const QItemSelection& ) ) );

    connect( treeWidgetCAs, SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int ) ),
             this, SLOT( handleDoubleClick( QTreeWidgetItem *, int ) ) );

    connect( btnViewRefresh, SIGNAL( clicked() ), this, SLOT( refreshCaCertsView() ) );

    QVariant cafileval = QgsAuthManager::instance()->getAuthSetting( QStringLiteral( "cafile" ) );
    if ( !cafileval.isNull() )
    {
      leCaFile->setText( cafileval.toString() );
    }

    btnGroupByOrg->setChecked( false );
    QVariant sortbyval = QgsAuthManager::instance()->getAuthSetting( QStringLiteral( "casortby" ), QVariant( false ) );
    if ( !sortbyval.isNull() )
      btnGroupByOrg->setChecked( sortbyval.toBool() );

    mDefaultTrustPolicy = QgsAuthManager::instance()->defaultCertTrustPolicy();
    populateCaCertsView();
    checkSelection();

    populateUtilitiesMenu();
  }
}
Exemplo n.º 12
0
QgsAuthAuthoritiesEditor::QgsAuthAuthoritiesEditor( QWidget *parent )
  : QWidget( parent )
{
  if ( QgsAuthManager::instance()->isDisabled() )
  {
    mDisabled = true;
    mAuthNotifyLayout = new QVBoxLayout;
    this->setLayout( mAuthNotifyLayout );
    mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
    mAuthNotifyLayout->addWidget( mAuthNotify );
  }
  else
  {
    setupUi( this );
    connect( btnAddCa, &QToolButton::clicked, this, &QgsAuthAuthoritiesEditor::btnAddCa_clicked );
    connect( btnRemoveCa, &QToolButton::clicked, this, &QgsAuthAuthoritiesEditor::btnRemoveCa_clicked );
    connect( btnInfoCa, &QToolButton::clicked, this, &QgsAuthAuthoritiesEditor::btnInfoCa_clicked );
    connect( btnGroupByOrg, &QToolButton::toggled, this, &QgsAuthAuthoritiesEditor::btnGroupByOrg_toggled );
    connect( btnCaFile, &QToolButton::clicked, this, &QgsAuthAuthoritiesEditor::btnCaFile_clicked );
    connect( btnCaFileClear, &QToolButton::clicked, this, &QgsAuthAuthoritiesEditor::btnCaFileClear_clicked );

    connect( QgsAuthManager::instance(), &QgsAuthManager::messageOut,
             this, &QgsAuthAuthoritiesEditor::authMessageOut );

    connect( QgsAuthManager::instance(), &QgsAuthManager::authDatabaseChanged,
             this, &QgsAuthAuthoritiesEditor::refreshCaCertsView );

    setupCaCertsTree();

    connect( treeWidgetCAs->selectionModel(), &QItemSelectionModel::selectionChanged,
             this, &QgsAuthAuthoritiesEditor::selectionChanged );

    connect( treeWidgetCAs, &QTreeWidget::itemDoubleClicked,
             this, &QgsAuthAuthoritiesEditor::handleDoubleClick );

    connect( btnViewRefresh, &QAbstractButton::clicked, this, &QgsAuthAuthoritiesEditor::refreshCaCertsView );

    QVariant cafileval = QgsAuthManager::instance()->getAuthSetting( QStringLiteral( "cafile" ) );
    if ( !cafileval.isNull() )
    {
      leCaFile->setText( cafileval.toString() );
    }

    btnGroupByOrg->setChecked( false );
    QVariant sortbyval = QgsAuthManager::instance()->getAuthSetting( QStringLiteral( "casortby" ), QVariant( false ) );
    if ( !sortbyval.isNull() )
      btnGroupByOrg->setChecked( sortbyval.toBool() );

    mDefaultTrustPolicy = QgsAuthManager::instance()->defaultCertTrustPolicy();
    populateCaCertsView();
    checkSelection();

    populateUtilitiesMenu();
  }
}
Exemplo n.º 13
0
void SensorWidget::onSelectionChanged()
{
    Qt::CheckState state = checkSelection();
    ui->exportTrace->setEnabled(state != Qt::Unchecked);
    if(state == Qt::Checked)
        ui->allNoneBox->setCheckState(Qt::Checked);
    else if(state == Qt::Unchecked)
        ui->allNoneBox->setCheckState(Qt::Unchecked);
    else
        ui->allNoneBox->setCheckState(Qt::PartiallyChecked);
}
Exemplo n.º 14
0
void QgsMapToolAddPart::canvasReleaseEvent( QgsMapMouseEvent *e )
{
  if ( checkSelection() )
  {
    QgsMapToolAdvancedDigitizing::canvasReleaseEvent( e );
  }
  else
  {
    cadDockWidget()->clear();
  }
}
Exemplo n.º 15
0
void CQBarChart::saveDataToFile()
{
#ifdef DEBUG_UI
  qDebug() << "-- in qwt3dPlot.cpp Plot3d::saveDataToFile --";
#endif
  C_INT32 Answer = QMessageBox::No;
  QString fileName, filetype_; //, newFilter;

  while (Answer == QMessageBox::No)
    {

      QString *userFilter = new QString;

      fileName =
        CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
                                          "ILDMResults-barsPrint", "BMP Files (*.bmp);;PS Files (*.ps);;PDF Files (*.pdf)", "Save to",
                                          userFilter);

      if (fileName.isNull()) return;

      if (*userFilter == "BMP Files (*.bmp)")
        filetype_ = "BMP";
      else if (*userFilter == "PS Files (*.ps)")
        filetype_ = "PS";
      else if (*userFilter == "PDF Files (*.pdf)")
        filetype_ = "PDF";

#ifdef DEBUG_UI
      qDebug() << "user's filter pointer = " << *userFilter;
      qDebug() << "filetype_ = " << filetype_;
#endif

      // Checks whether the file exists
      Answer = checkSelection(fileName);

      if (Answer == QMessageBox::Cancel) return;
    }

  int failed = 0;
  QCursor oldCursor = cursor();
  setCursor(Qt::WaitCursor);
  failed = !Qwt3D::IO::save(mpPlot, fileName, filetype_);
  setCursor(oldCursor);

  if (failed)
    {
      std::string s = "Could not save data to ";
      s += TO_UTF8(fileName);
      CQMessageBox::critical(this, "Save Error", FROM_UTF8(s), QMessageBox::Ok, QMessageBox::Ok);
    }
}
Exemplo n.º 16
0
void CQDifferentialEquations::slotSave()
{
  QString outfilename;

  C_INT32 Answer = QMessageBox::No;

  while (Answer == QMessageBox::No)
    {
      outfilename =
        CopasiFileDialog::getSaveFileName(this,
                                          "Save File Dialog",
                                          "untitled.mml",
                                          "MathML (*.mml);;TeX (*.tex);;PNG (*.png)",
                                          "Save Formula to Disk", new QString);

      if (outfilename.isEmpty()) return;

      // Checks whether the file exists
      Answer = checkSelection(outfilename);

      if (Answer == QMessageBox::Cancel)
        return;
    }

#ifdef DEBUG_UI
  qDebug() << "outfilename = " << outfilename;
#endif

  QApplication::setOverrideCursor(Qt::WaitCursor);

  if (outfilename.contains(".tex"))
    {
      saveTeX(outfilename);
    }
  else if (outfilename.contains(".png"))
    {
      savePNG(outfilename);
    }
  else
    {
      saveMML(outfilename);
    }

  QApplication::restoreOverrideCursor();
}
Exemplo n.º 17
0
QgsAuthIdentitiesEditor::QgsAuthIdentitiesEditor( QWidget *parent )
    : QWidget( parent )
    , mDisabled( false )
    , mAuthNotifyLayout( 0 )
    , mAuthNotify( 0 )
    , mRootCertIdentItem( 0 )
{
  if ( QgsAuthManager::instance()->isDisabled() )
  {
    mDisabled = true;
    mAuthNotifyLayout = new QVBoxLayout;
    this->setLayout( mAuthNotifyLayout );
    mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
    mAuthNotifyLayout->addWidget( mAuthNotify );
  }
  else
  {
    setupUi( this );

    connect( QgsAuthManager::instance(), SIGNAL( messageOut( const QString&, const QString&, QgsAuthManager::MessageLevel ) ),
             this, SLOT( authMessageOut( const QString&, const QString&, QgsAuthManager::MessageLevel ) ) );

    connect( QgsAuthManager::instance(), SIGNAL( authDatabaseChanged() ),
             this, SLOT( refreshIdentitiesView() ) );

    setupIdentitiesTree();

    connect( treeIdentities->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
             this, SLOT( selectionChanged( const QItemSelection&, const QItemSelection& ) ) );

    connect( treeIdentities, SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int ) ),
             this, SLOT( handleDoubleClick( QTreeWidgetItem *, int ) ) );

    connect( btnViewRefresh, SIGNAL( clicked() ), this, SLOT( refreshIdentitiesView() ) );

    btnGroupByOrg->setChecked( false );
    QVariant sortbyval = QgsAuthManager::instance()->getAuthSetting( QString( "identitiessortby" ), QVariant( false ) );
    if ( !sortbyval.isNull() )
      btnGroupByOrg->setChecked( sortbyval.toBool() );

    populateIdentitiesView();
    checkSelection();
  }
}
Exemplo n.º 18
0
QgsAuthServersEditor::QgsAuthServersEditor( QWidget *parent )
  : QWidget( parent )
{
  if ( QgsAuthManager::instance()->isDisabled() )
  {
    mDisabled = true;
    mAuthNotifyLayout = new QVBoxLayout;
    this->setLayout( mAuthNotifyLayout );
    mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
    mAuthNotifyLayout->addWidget( mAuthNotify );
  }
  else
  {
    setupUi( this );
    connect( btnAddServer, &QToolButton::clicked, this, &QgsAuthServersEditor::btnAddServer_clicked );
    connect( btnRemoveServer, &QToolButton::clicked, this, &QgsAuthServersEditor::btnRemoveServer_clicked );
    connect( btnEditServer, &QToolButton::clicked, this, &QgsAuthServersEditor::btnEditServer_clicked );
    connect( btnGroupByOrg, &QToolButton::toggled, this, &QgsAuthServersEditor::btnGroupByOrg_toggled );

    connect( QgsAuthManager::instance(), &QgsAuthManager::messageOut,
             this, &QgsAuthServersEditor::authMessageOut );

    connect( QgsAuthManager::instance(), &QgsAuthManager::authDatabaseChanged,
             this, &QgsAuthServersEditor::refreshSslConfigsView );

    setupSslConfigsTree();

    connect( treeServerConfigs->selectionModel(), &QItemSelectionModel::selectionChanged,
             this, &QgsAuthServersEditor::selectionChanged );

    connect( treeServerConfigs, &QTreeWidget::itemDoubleClicked,
             this, &QgsAuthServersEditor::handleDoubleClick );

    connect( btnViewRefresh, &QAbstractButton::clicked, this, &QgsAuthServersEditor::refreshSslConfigsView );

    btnGroupByOrg->setChecked( false );
    QVariant sortbyval = QgsAuthManager::instance()->getAuthSetting( QStringLiteral( "serverssortby" ), QVariant( false ) );
    if ( !sortbyval.isNull() )
      btnGroupByOrg->setChecked( sortbyval.toBool() );

    populateSslConfigsView();
    checkSelection();
  }
}
Exemplo n.º 19
0
//Begins Text Input
void getText(char *buffer)
{
	int FINISHED = 0;
	clearScreen();
	setupInterrupts();
	initializeSprites();
	drawKeyboard();
	playBG = TRUE;	
	while(!FINISHED)
	{
		if(playBG && !BGplaying)
        {
            // play the bg music
            DMA[2].cnt |= DMA_ON;
            REG_TM1CNT |= TM_ON;
            startBG = vblankcount;
            BGplaying = TRUE;
            DMA[2].src = flute;
        }
		checkMovement();
		//Check Input and End Function if finished
		if(!endInput)
		{
			checkSelection(buffer);
			copyShadow();
			waitForVblank();
			moveSpriteToMem();
		}
		else
		{
			DMA[2].cnt &= ~DMA_ON;
            REG_TM1CNT &= ~TM_ON;
			playBG = FALSE;
			waitForVblank();
			FINISHED = 1;
			resetVariables();
			endInput = 0;
			resetCursor();
		}
		
	}
	clearScreen();
}
Exemplo n.º 20
0
QgsAuthTrustedCAsDialog::QgsAuthTrustedCAsDialog( QWidget *parent,
    const QList<QSslCertificate>& trustedCAs )
    : QDialog( parent )
    , mTrustedCAs( trustedCAs )
    , mDisabled( false )
    , mAuthNotifyLayout( nullptr )
    , mAuthNotify( nullptr )
    , mRootCaSecItem( nullptr )
{
  if ( QgsAuthManager::instance()->isDisabled() )
  {
    mDisabled = true;
    mAuthNotifyLayout = new QVBoxLayout;
    this->setLayout( mAuthNotifyLayout );
    mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
    mAuthNotifyLayout->addWidget( mAuthNotify );
  }
  else
  {
    setupUi( this );

    connect( QgsAuthManager::instance(), SIGNAL( messageOut( const QString&, const QString&, QgsAuthManager::MessageLevel ) ),
             this, SLOT( authMessageOut( const QString&, const QString&, QgsAuthManager::MessageLevel ) ) );

    setupCaCertsTree();

    connect( treeTrustedCAs->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
             this, SLOT( selectionChanged( const QItemSelection&, const QItemSelection& ) ) );

    connect( treeTrustedCAs, SIGNAL( itemDoubleClicked( QTreeWidgetItem *, int ) ),
             this, SLOT( handleDoubleClick( QTreeWidgetItem *, int ) ) );


    btnGroupByOrg->setChecked( false );
    QVariant sortbyval = QgsAuthManager::instance()->getAuthSetting( QStringLiteral( "trustedcasortby" ), QVariant( false ) );
    if ( !sortbyval.isNull() )
      btnGroupByOrg->setChecked( sortbyval.toBool() );

    populateCaCertsView();
    checkSelection();
  }
}
Exemplo n.º 21
0
QgsAuthTrustedCAsDialog::QgsAuthTrustedCAsDialog( QWidget *parent,
    const QList<QSslCertificate> &trustedCAs )
  : QDialog( parent )
  , mTrustedCAs( trustedCAs )
{
  if ( QgsApplication::authManager()->isDisabled() )
  {
    mDisabled = true;
    mAuthNotifyLayout = new QVBoxLayout;
    this->setLayout( mAuthNotifyLayout );
    mAuthNotify = new QLabel( QgsApplication::authManager()->disabledMessage(), this );
    mAuthNotifyLayout->addWidget( mAuthNotify );
  }
  else
  {
    setupUi( this );
    connect( btnInfoCa, &QToolButton::clicked, this, &QgsAuthTrustedCAsDialog::btnInfoCa_clicked );
    connect( btnGroupByOrg, &QToolButton::toggled, this, &QgsAuthTrustedCAsDialog::btnGroupByOrg_toggled );

    connect( QgsApplication::authManager(), &QgsAuthManager::messageOut,
             this, &QgsAuthTrustedCAsDialog::authMessageOut );

    setupCaCertsTree();

    connect( treeTrustedCAs->selectionModel(), &QItemSelectionModel::selectionChanged,
             this, &QgsAuthTrustedCAsDialog::selectionChanged );

    connect( treeTrustedCAs, &QTreeWidget::itemDoubleClicked,
             this, &QgsAuthTrustedCAsDialog::handleDoubleClick );


    btnGroupByOrg->setChecked( false );
    QVariant sortbyval = QgsApplication::authManager()->authSetting( QStringLiteral( "trustedcasortby" ), QVariant( false ) );
    if ( !sortbyval.isNull() )
      btnGroupByOrg->setChecked( sortbyval.toBool() );

    populateCaCertsView();
    checkSelection();
  }
}
Exemplo n.º 22
0
void PlotWindow::printAsImage()
{
  // take a name from QFileDialog

  C_INT32 Answer = QMessageBox::No;
  QString fileName, extensionName;

  while (Answer == QMessageBox::No)
    {

//      QString userFilter = new QString;
      /*
            fileName = CopasiFileDialog::getSaveFileNameAndFilter(filter, this, "Save File Dialog",
                       QString::null, "PNG Files (*.png);;SVG Files (*.svg)", "Save to");
      */
      fileName = CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
                 "untitled.png", "PDF Files (*.pdf);;PNG Files (*.png);;SVG Files (*.svg)", "Save Plot as Image", new QString);

      if (fileName.isEmpty()) return;

      /*
            QFileInfo fileInfo(fileName);
            extensionName = fileInfo.extension();
      */
#ifdef DEBUG_UI
//      qDebug() << "extensionName = " << extensionName;
#endif

      // check whether the file exists
      Answer = checkSelection(fileName);

      if (Answer == QMessageBox::Cancel) return;
    }

  // print plot as an image
  saveToFile(fileName);
}
Exemplo n.º 23
0
void CQExpressionMmlStackedWidget::slotSaveExpression()
{
  QString *filter = new QString;
  QString outfilename;

  C_INT32 Answer = QMessageBox::No;

  while (Answer == QMessageBox::No)
    {
      outfilename =
        CopasiFileDialog::getSaveFileName(this,
                                          "Save File Dialog",
                                          "untitled.mml",
                                          "MathML (*.mml);;TeX (*.tex);;PNG (*.png)",
//                                          "Save Expression to Disk", new QString);
                                          "Save Expression to Disk", filter);

      if (outfilename.isEmpty()) return;

      // Checks whether the file exists
      Answer = checkSelection(outfilename);

      if (Answer == QMessageBox::Cancel)
        return;
    }

#ifdef DEBUG_UI
  qDebug() << "\non CQEMSW::slotSaveExpression -> filter = " << *filter << "\n";
#endif

  if (filter->contains(".tex"))
    saveTeX(outfilename);
  else if (filter->contains(".png"))
    savePNG(outfilename);
  else
    saveMML(outfilename);
}
Exemplo n.º 24
0
//Begins Text Input
void getText(char *buffer)
{
	setRegister();
	setupInterrupts();
	initializeTiles();
	initializeSprites();
	drawKeyboard();
	playBG = TRUE;	
	while(1)
	{
		if(playBG && !BGplaying)
        {
            // play the bg music
            DMA[2].cnt |= DMA_ON;
            REG_TM1CNT |= TM_ON;
            startBG = vblankcount;
            BGplaying = TRUE;
            DMA[2].src = flute;
        }
		checkMovement();
		if(!endInput)
		{
			checkSelection(buffer);
		}
		else
		{
			DMA[2].cnt &= ~DMA_ON;
            REG_TM1CNT &= ~TM_ON;
			playBG = FALSE;
			waitForVblank();
		}
		copyShadow();
		waitForVblank();
		moveSpriteToMem();
	}
}
Exemplo n.º 25
0
void QgsMapToolAddPart::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
{
  //check if we operate on a vector layer
  QgsVectorLayer *vlayer = currentVectorLayer();
  if ( !vlayer )
  {
    notifyNotVectorLayer();
    return;
  }

  if ( !vlayer->isEditable() )
  {
    notifyNotEditableLayer();
    return;
  }

  bool isGeometryEmpty = false;
  QgsFeatureList selectedFeatures = vlayer->selectedFeatures();
  if ( !selectedFeatures.isEmpty() && selectedFeatures.at( 0 ).geometry().isNull() )
    isGeometryEmpty = true;

  if ( !checkSelection() )
  {
    stopCapturing();
    return;
  }

  int errorCode = 0;
  switch ( mode() )
  {
    case CapturePoint:
    {
      QgsPoint layerPoint;
      QgsPointXY mapPoint = e->mapPoint();

      if ( nextPoint( QgsPoint( mapPoint ), layerPoint ) != 0 )
      {
        QgsDebugMsg( "nextPoint failed" );
        return;
      }

      vlayer->beginEditCommand( tr( "Part added" ) );
      errorCode = vlayer->addPart( QgsPointSequence() << layerPoint );
    }
    break;

    case CaptureLine:
    case CapturePolygon:
    {
      //add point to list and to rubber band
      if ( e->button() == Qt::LeftButton )
      {
        int error = addVertex( e->mapPoint(), e->mapPointMatch() );
        if ( error == 1 )
        {
          QgsDebugMsg( "current layer is not a vector layer" );
          return;
        }
        else if ( error == 2 )
        {
          //problem with coordinate transformation
          emit messageEmitted( tr( "Coordinate transform error. Cannot transform the point to the layers coordinate system" ), Qgis::Warning );
          return;
        }

        startCapturing();
        return;
      }
      else if ( e->button() != Qt::RightButton )
      {
        deleteTempRubberBand();

        return;
      }

      if ( !isCapturing() )
        return;

      if ( mode() == CapturePolygon )
      {
        closePolygon();
      }

      //does compoundcurve contain circular strings?
      //does provider support circular strings?
      bool hasCurvedSegments = captureCurve()->hasCurvedSegments();
      bool providerSupportsCurvedSegments = vlayer->dataProvider()->capabilities() & QgsVectorDataProvider::CircularGeometries;

      QgsCurve *curveToAdd = nullptr;
      if ( hasCurvedSegments && providerSupportsCurvedSegments )
      {
        curveToAdd = captureCurve()->clone();
      }
      else
      {
        curveToAdd = captureCurve()->curveToLine();
      }

      vlayer->beginEditCommand( tr( "Part added" ) );
      if ( mode() == CapturePolygon )
      {
        //avoid intersections
        QgsCurvePolygon *cp = new QgsCurvePolygon();
        cp->setExteriorRing( curveToAdd );
        QgsGeometry *geom = new QgsGeometry( cp );
        geom->avoidIntersections( QgsProject::instance()->avoidIntersectionsLayers() );

        const QgsCurvePolygon *cpGeom = qgsgeometry_cast<const QgsCurvePolygon *>( geom->constGet() );
        if ( !cpGeom )
        {
          stopCapturing();
          delete geom;
          vlayer->destroyEditCommand();
          return;
        }

        errorCode = vlayer->addPart( cpGeom->exteriorRing()->clone() );
        delete geom;
      }
      else
      {
        errorCode = vlayer->addPart( curveToAdd );
      }
      stopCapturing();
    }
    break;
    default:
      Q_ASSERT( !"invalid capture mode" );
      errorCode = 6;
      break;
  }

  QString errorMessage;
  switch ( errorCode )
  {
    case 0:
    {
      // remove previous message
      emit messageDiscarded();

      //add points to other features to keep topology up-to-date
      bool topologicalEditing = QgsProject::instance()->topologicalEditing();
      if ( topologicalEditing )
      {
        addTopologicalPoints( points() );
      }

      vlayer->endEditCommand();

      vlayer->triggerRepaint();

      if ( ( !isGeometryEmpty ) && QgsWkbTypes::isSingleType( vlayer->wkbType() ) )
      {
        emit messageEmitted( tr( "Add part: Feature geom is single part and you've added more than one" ), Qgis::Warning );
      }

      return;
    }

    case 1:
      errorMessage = tr( "Selected feature is not multi part." );
      break;

    case 2:
      errorMessage = tr( "New part's geometry is not valid." );
      break;

    case 3:
      errorMessage = tr( "New polygon ring not disjoint with existing polygons." );
      break;

    case 4:
      errorMessage = tr( "No feature selected. Please select a feature with the selection tool or in the attribute table" );
      break;

    case 5:
      errorMessage = tr( "Several features are selected. Please select only one feature to which an island should be added." );
      break;

    case 6:
      errorMessage = tr( "Selected geometry could not be found" );
      break;
  }

  emit messageEmitted( errorMessage, Qgis::Warning );
  vlayer->destroyEditCommand();
}
Exemplo n.º 26
0
void QgsMapToolAddPart::activate()
{
  checkSelection();
  QgsMapToolCapture::activate();
}
QgsAuthConfigEditor::QgsAuthConfigEditor( QWidget *parent )
    : QWidget( parent )
    , mConfigModel( 0 )
    , mAuthUtilitiesMenu( 0 )
    , mActionSetMasterPassword( 0 )
    , mActionClearCachedMasterPassword( 0 )
    , mActionResetMasterPassword( 0 )
    , mActionClearCachedAuthConfigs( 0 )
    , mActionRemoveAuthConfigs( 0 )
    , mActionEraseAuthDatabase( 0 )
    , mAuthNotifyLayout( 0 )
    , mAuthNotify( 0 )
{
  if ( QgsAuthManager::instance()->isDisabled() )
  {
    mAuthNotifyLayout = new QVBoxLayout;
    this->setLayout( mAuthNotifyLayout );
    mAuthNotify = new QLabel( QgsAuthManager::instance()->disabledMessage(), this );
    mAuthNotifyLayout->addWidget( mAuthNotify );
  }
  else
  {
    setupUi( this );
    mConfigModel = new QSqlTableModel( this, QgsAuthManager::instance()->authDbConnection() );
    mConfigModel->setTable( QgsAuthManager::instance()->authDbConfigTable() );
    mConfigModel->select();

    mConfigModel->setHeaderData( 0, Qt::Horizontal, tr( "ID" ) );
    mConfigModel->setHeaderData( 1, Qt::Horizontal, tr( "Name" ) );
    mConfigModel->setHeaderData( 2, Qt::Horizontal, tr( "URI" ) );
    mConfigModel->setHeaderData( 3, Qt::Horizontal, tr( "Type" ) );
    mConfigModel->setHeaderData( 4, Qt::Horizontal, tr( "Version" ) );
    mConfigModel->setHeaderData( 5, Qt::Horizontal, tr( "Config" ) );

    tableViewConfigs->setModel( mConfigModel );
    tableViewConfigs->resizeColumnsToContents();
//    tableViewConfigs->resizeColumnToContents( 0 );
//    tableViewConfigs->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch);
//    tableViewConfigs->horizontalHeader()->setResizeMode(2, QHeaderView::Interactive);
//    tableViewConfigs->resizeColumnToContents( 3 );
    tableViewConfigs->hideColumn( 4 );
    tableViewConfigs->hideColumn( 5 );

    // sort by config 'name'
    tableViewConfigs->sortByColumn( 1, Qt::AscendingOrder );
    tableViewConfigs->setSortingEnabled( true );

    connect( tableViewConfigs->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ),
             this, SLOT( selectionChanged( const QItemSelection&, const QItemSelection& ) ) );

    connect( tableViewConfigs, SIGNAL( doubleClicked( QModelIndex ) ),
             this, SLOT( on_btnEditConfig_clicked() ) );

    connect( QgsAuthManager::instance(), SIGNAL( messageOut( const QString&, const QString&, QgsAuthManager::MessageLevel ) ),
             this, SLOT( authMessageOut( const QString&, const QString&, QgsAuthManager::MessageLevel ) ) );

    checkSelection();

    // set up utility actions menu
    mActionSetMasterPassword = new QAction( "Input master password", this );
    mActionClearCachedMasterPassword = new QAction( "Clear cached master password", this );
    mActionResetMasterPassword = new QAction( "Reset master password", this );
    mActionClearCachedAuthConfigs = new QAction( "Clear cached authentication configurations", this );
    mActionRemoveAuthConfigs = new QAction( "Remove all authentication configurations", this );
    mActionEraseAuthDatabase = new QAction( "Erase authentication database", this );

    connect( mActionSetMasterPassword, SIGNAL( triggered() ), this, SLOT( setMasterPassword() ) );
    connect( mActionClearCachedMasterPassword, SIGNAL( triggered() ), this, SLOT( clearCachedMasterPassword() ) );
    connect( mActionResetMasterPassword, SIGNAL( triggered() ), this, SLOT( resetMasterPassword() ) );
    connect( mActionClearCachedAuthConfigs, SIGNAL( triggered() ), this, SLOT( clearCachedAuthenticationConfigs() ) );
    connect( mActionRemoveAuthConfigs, SIGNAL( triggered() ), this, SLOT( removeAuthenticationConfigs() ) );
    connect( mActionEraseAuthDatabase, SIGNAL( triggered() ), this, SLOT( eraseAuthenticationDatabase() ) );

    mAuthUtilitiesMenu = new QMenu( this );
    mAuthUtilitiesMenu->addAction( mActionSetMasterPassword );
    mAuthUtilitiesMenu->addAction( mActionClearCachedMasterPassword );
    mAuthUtilitiesMenu->addAction( mActionResetMasterPassword );
    mAuthUtilitiesMenu->addSeparator();
    mAuthUtilitiesMenu->addAction( mActionClearCachedAuthConfigs );
    mAuthUtilitiesMenu->addAction( mActionRemoveAuthConfigs );
    mAuthUtilitiesMenu->addSeparator();
    mAuthUtilitiesMenu->addAction( mActionEraseAuthDatabase );

    btnAuthUtilities->setMenu( mAuthUtilitiesMenu );
  }
}
void QgsAuthConfigEditor::selectionChanged( const QItemSelection& selected , const QItemSelection& deselected )
{
  Q_UNUSED( selected );
  Q_UNUSED( deselected );
  checkSelection();
}
Exemplo n.º 29
0
void CQFittingResult::slotSave(void)
{
  C_INT32 Answer = QMessageBox::No;
  QString fileName;

  while (Answer == QMessageBox::No)
    {
      fileName =
        CopasiFileDialog::getSaveFileName(this,
                                          "Save File Dialog",
                                          "untitled.txt",
                                          "TEXT Files (*.txt)",
                                          "Save to");

      if (fileName.isEmpty()) return;

      if (!fileName.endsWith(".txt") &&
          !fileName.endsWith(".")) fileName += ".txt";

      fileName = fileName.remove(QRegExp("\\.$"));

      Answer = checkSelection(fileName);

      if (Answer == QMessageBox::Cancel) return;
    }

  std::ofstream file(CLocaleString::fromUtf8(TO_UTF8(fileName)).c_str());

  if (file.fail()) return;

  size_t i, imax;

  // The global result and statistics
  file << "Objective Value\tRoot Mean Square\tStandard Deviation" << std::endl;
  file << mpProblem->getSolutionValue() << "\t";
  file << mpProblem->getRMS() << "\t";
  file << mpProblem->getStdDeviation() << std::endl;

  file << "Function Evaluations\tCPU Time [s]\tEvaluations/second [1/s]" << std::endl;
  const unsigned C_INT32 & FunctionEvaluations = mpProblem->getFunctionEvaluations();
  const C_FLOAT64 & ExecutionTime = mpProblem->getExecutionTime();
  file << FunctionEvaluations << "\t";
  file << ExecutionTime << "\t";
  file << FunctionEvaluations / ExecutionTime << std::endl;

  // Set up the parameters table
  file << std::endl << "Parameters:" << std::endl;
  file << "Parameter\tValue\tStd. Deviation\tCoeff. of Variation [%]\tGradient" << std::endl;

  // Loop over the optimization items
  const std::vector< COptItem * > & Items = mpProblem->getOptItemList();
  const CVector< C_FLOAT64 > & Solutions = mpProblem->getSolutionVariables();
  const CVector< C_FLOAT64 > & StdDeviations = mpProblem->getVariableStdDeviations();
  const CVector< C_FLOAT64 > & Gradients = mpProblem->getVariableGradients();

  imax = Items.size();

  if (mpProblem->getFunctionEvaluations() == 0)
    imax = 0;

  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);

  for (i = 0; i != imax; i++)
    {
      const CCopasiObject *pObject =
        pDataModel->getDataObject(Items[i]->getObjectCN());

      if (pObject)
        {
          std::string Experiments =
            static_cast<CFitItem *>(Items[i])->getExperiments();

          if (Experiments != "")
            Experiments = "; {" + Experiments + "}";

          file << pObject->getObjectDisplayName() << Experiments << "\t";
        }
      else
        file << "Not Found\t";

      const C_FLOAT64 & Solution = Solutions[i];
      file << Solution << "\t";
      const C_FLOAT64 & StdDeviation = StdDeviations[i];
      file << StdDeviation << "\t";
      file << fabs(100.0 * StdDeviation / Solution) << "\t";
      file << Gradients[i] << std::endl;
    }

  // Set up the experiments table
  file << std::endl << "Experiments:" << std::endl;
  file << "Experiment\tObjective Value\tRoot Mean Square\tError Mean\tError Mean Std. Deviation" << std::endl;

  // Loop over the experiments
  const CExperimentSet & Experiments = mpProblem->getExperiementSet();

  imax = Experiments.getExperimentCount();

  if (mpProblem->getFunctionEvaluations() == 0)
    imax = 0;

  for (i = 0; i != imax; i++)
    {
      const CExperiment & Experiment = * Experiments.getExperiment(i);
      file << Experiment.getObjectName() << "\t";
      file << Experiment.getObjectiveValue() << "\t";
      file << Experiment.getRMS() << "\t";
      file << Experiment.getErrorMean() << "\t";
      file << Experiment.getErrorMeanSD() << std::endl;
    }

  // Set up the fitted values table
  file << std::endl << "Fitted Values:" << std::endl;
  file << "Fitted Value\tObjective Value\tRoot Mean Square\tError Mean\tError Mean Std. Deviation" << std::endl;

  // Loop over the fitted values objects
  imax = Experiments.getDependentObjects().size();

  if (mpProblem->getFunctionEvaluations() == 0)
    imax = 0;

  for (i = 0; i != imax; i++)
    {
      const CCopasiObject * pObject = Experiments.getDependentObjects()[i];

      if (pObject)
        file << pObject->getObjectDisplayName() << "\t";
      else
        file << "Not Found\t";

      file << Experiments.getDependentObjectiveValues()[i] << "\t";
      file << Experiments.getDependentRMS()[i] << "\t";
      file << Experiments.getDependentErrorMean()[i] << "\t";
      file << Experiments.getDependentErrorMeanSD()[i] << std::endl;
    }

  file << std::endl;

  // Save the parameter correlations
  file << mpProblem->getCorrelations() << std::endl;

  // Save the Fisher information
  file << mpProblem->getFisherInformation() << std::endl;

  const CCrossValidationSet & CrossValidations = mpProblem->getCrossValidationSet();
  imax = CrossValidations.getExperimentCount();

  if (mpProblem->getFunctionEvaluations() == 0)
    imax = 0;

  if (imax)
    {
      // Set up the cross validations table
      file << std::endl << "Validations:" << std::endl;
      file << "Validation Experiment\t Objective Value\tRoot Mean Square\tError Mean\tError Mean Std. Deviation" << std::endl;

      // Loop over the cross validations
      for (i = 0; i != imax; i++)
        {
          const CExperiment & Experiment = * CrossValidations.getExperiment(i);
          file << Experiment.getObjectName() << "\t";
          file << Experiment.getObjectiveValue() << "\t";
          file << Experiment.getRMS() << "\t";
          file << Experiment.getErrorMean() << "\t";
          file << Experiment.getErrorMeanSD() << std::endl;
        }
    }

  imax = CrossValidations.getDependentObjects().size();

  if (mpProblem->getFunctionEvaluations() == 0)
    imax = 0;

  if (imax)
    {
      // Set up the fitted values table
      file << std::endl << "Validation Fitted Values:" << std::endl;
      file << "Validation Fitted Value\tObjective Value\tRoot Mean Square\tError Mean\tError Mean Std. Deviation" << std::endl;

      // Loop over the fitted values objects
      for (i = 0; i != imax; i++)
        {
          const CCopasiObject * pObject = CrossValidations.getDependentObjects()[i];

          if (pObject)
            file << pObject->getObjectDisplayName() << "\t";
          else
            file << "Not Found\t";

          file << CrossValidations.getDependentObjectiveValues()[i] << "\t";
          file << CrossValidations.getDependentRMS()[i] << "\t";
          file << CrossValidations.getDependentErrorMean()[i] << "\t";
          file << CrossValidations.getDependentErrorMeanSD()[i] << std::endl;
        }
    }

  file << std::endl;
}
Exemplo n.º 30
0
void PlotWindow::printAsImage()
{
  // take a name from QFileDialog

  C_INT32 Answer = QMessageBox::No;
  QString fileName, extensionName;

  while (Answer == QMessageBox::No)
    {

//      QString userFilter = new QString;
      /*
            fileName = CopasiFileDialog::getSaveFileNameAndFilter(filter, this, "Save File Dialog",
                       QString::null, "PNG Files (*.png);;SVG Files (*.svg)", "Save to");
      */
      fileName = CopasiFileDialog::getSaveFileName(this, "Save File Dialog",
                 "untitled.png", "PDF Files (*.pdf);;PNG Files (*.png);;SVG Files (*.svg)", "Save Plot as Image", new QString);

      if (fileName.isEmpty()) return;

      /*
            QFileInfo fileInfo(fileName);
            extensionName = fileInfo.extension();
      */
#ifdef DEBUG_UI
//      qDebug() << "extensionName = " << extensionName;
#endif

      // check whether the file exists
      Answer = checkSelection(fileName);

      if (Answer == QMessageBox::Cancel) return;
    }

  // print plot as an image

  QRect rect;
  rect.setSize(this->size());

  if (fileName.endsWith(".png"))
    {
      QPixmap pixmap(rect.width(), rect.height());
      pixmap.fill();
      QPainter painter(&pixmap);
      painter.begin(&pixmap);
      mpPlot->print(&painter, rect, PrintFilter());
      painter.end();

      pixmap.save(fileName, "PNG");
    }
  else if (fileName.endsWith(".svg"))
    {
      QSvgGenerator generator;
      generator.setFileName(fileName);
      QPainter painter(&generator);
      painter.begin(&generator);
      mpPlot->print(&painter, rect, PrintFilter());
      painter.end();
    }
  else if (fileName.endsWith(".pdf"))
    {
      QPrinter printer;
      printer.setOutputFileName(fileName);
      printer.setOutputFormat(QPrinter::PdfFormat);
      QPainter painter(&printer);
      painter.begin(&printer);
      mpPlot->print(&painter, rect, PrintFilter());
      painter.end();
    }
}