MainWindow::MainWindow(QWidget *parent) :
    initialized(false),
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    //constants
    const double beamLength = 1;

    //initializing the UI
    ui->setupUi(this);

    //initializing the standard materials and cross sections
    for (int i=0; i< standardMaterials.count(); i++ )
        ui->material->addItem(standardMaterials.get(i)->GetName());

    for (int i=0; i< standardCrossSections.count(); i++ ) {
        CrossSection *cs = standardCrossSections.get(i);
        cs->constructForm(beamLength);
        ui->crossSection->addItem(cs->getName());
        QObject::connect(cs->getForm(), SIGNAL(crossSectionUpdated()), this, SLOT(onCrossSectionUpdated()));
        QObject::connect(this, SIGNAL(beamLengthChanged(double)), cs->getForm(), SLOT(onBeamLengthChanged(double)));
    }
    crossSectionWidget = standardCrossSections.get(0)->getForm();


    //initializing the the models
        //constructing initial beam, load and bending manipulator

    beam = new Beam();
    load = new Load(beam);
    standardBendingManipulators = new StandardBendingManipulators(beam, load);

    //initializing the model and UI values

        //beam options
        setBeamLength(beamLength);
        setCrossSection();
        setMaterial();

        //loading options
        setLoadPosition(beam->GetLength());
        setLoadValue(10);
        setLoadOptionUniform();

        //bending manipulator
        setBendingManipulator();


    //initializaing and connecting widgets
    bendingWidget = new shower(this, bendingManipulator);
    ui->beamBending->addWidget(bendingWidget);
    ui->crossSectionLayout->addWidget(crossSectionWidget);
    QObject::connect(this, SIGNAL(modelUpdated()), this, SLOT(updateBendingWidget()));
    QObject::connect(this, SIGNAL(modelUpdated()), this, SLOT(updateStressValues()));
    updateStressValues();

    //variable used to disable invoking of some signals without the complete construction of the MainWindow
    initialized = true;
}
Example #2
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    this->model = new SailSizeModel(parent, 80);
    this->windSizeTableModel = new WindSizeTableModel(this, this->model);
    // connect the weightslider to the model
    QObject::connect(ui->weightSlider,SIGNAL(valueChanged(int)), this->model, SLOT(setWeight(int)));

    // connect the fromWindSlider to the model
    QObject::connect(ui->windSlider1,SIGNAL(valueChanged(int)),
                     this, SLOT(setWindSpeed(int)));

    // connect the fromWindSlider to the model
    QObject::connect(ui->windSlider2,SIGNAL(valueChanged(int)),
                     this, SLOT(setWindSpeed(int)));

    // connect the model update signal to the main window
    QObject::connect(this->model,SIGNAL(updated()), this, SLOT(modelUpdated()));

    ui->weightSlider->setValue(this->model->weight());

    ui->weightLabel->setMinimumWidth(90);
    ui->windRangeLabel->setMinimumWidth(90);

    this->updateWeightLabel();
    this->updateWindRangeLabel();

    ui->sailSizeTable->setModel(this->windSizeTableModel);
    ui->sailSizeTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    // center window on screen
    QRect frect = frameGeometry();
    frect.moveCenter(QDesktopWidget().availableGeometry().center());
    move(frect.topLeft());
}
void MainWindow::setLoadPosition(double position)
{
    if (load->setLoadPosition(position)) {
        ui->loadPositionBox->setValue(load->getLoadPosition());
        emit modelUpdated();
    }
}
void MainWindow::on_uniformLoad_clicked(bool checked)
{
    if(checked) {
        load->setLoadOptionUniform();
        ui->loadPositionBox->setDisabled(true);
        ui->loadPositionLabel->setDisabled(true);
        emit modelUpdated();
    }
}
void MainWindow::on_singleLoad_clicked(bool checked)
{
    if(checked){
        load->setLoadOptionSingle();
        ui->loadPositionBox->setDisabled(false);
        ui->loadPositionLabel->setDisabled(false);
        emit modelUpdated();
    }
}
//controllers
void MainWindow::setBeamLength(double length)
{
    if (length != 0) {
        beam->SetLength(length);
        ui->length->setValue(length);
        ui->loadPositionBox->setRange(0, beam->GetLength());
        emit modelUpdated();
        emit beamLengthChanged(beam->GetLength());
    }
}
Example #7
0
void WeatherApplet::saveConfig(const QVariantMap& configChanges)
{
    // TODO: if just units where changed there is no need to reset the complete model or reconnect to engine
    resetPanelModel();
    m_fiveDaysModel.clear();
    m_detailsModel.clear();

    emit modelUpdated();

    WeatherPopupApplet::saveConfig(configChanges);
}
Example #8
0
void WeatherApplet::dataUpdated(const QString &source, const Plasma::DataEngine::Data &data)
{
    if (data.isEmpty()) {
        return;
    }

    updatePanelModel(data);
    updateFiveDaysModel(data);
    updateDetailsModel(data);
    updateNoticesModel(data);
    WeatherPopupApplet::dataUpdated(source, data);

    emit modelUpdated();
}
void MainWindow::setCrossSection(int index)
{

    //closing the previous cross section
    ui->crossSectionLayout->removeWidget(crossSectionWidget);
    crossSectionWidget->close();

    //loading the new cross section
    beam->SetCrossSection(standardCrossSections.get(index));
    crossSectionWidget = standardCrossSections.get(index)->getForm();
    crossSectionWidget->show();
    crossSectionWidget->setBeamLength(beam->GetLength());
    ui->crossSectionLayout->addWidget(crossSectionWidget, Qt::AlignTop);

    ui->crossSection->setCurrentIndex(index);

    emit modelUpdated();
}
Example #10
0
void QmlJSOutlineWidget::setEditor(QmlJSEditorWidget *editor)
{
    m_editor = editor;

    m_filterModel->setSourceModel(m_editor->qmlJsEditorDocument()->outlineModel());
    modelUpdated();

    connect(m_treeView->selectionModel(), &QItemSelectionModel::selectionChanged,
            this, &QmlJSOutlineWidget::updateSelectionInText);

    connect(m_treeView, &QAbstractItemView::activated,
            this, &QmlJSOutlineWidget::focusEditor);

    connect(m_editor, &QmlJSEditorWidget::outlineModelIndexChanged,
            this, &QmlJSOutlineWidget::updateSelectionInTree);
    connect(m_editor->qmlJsEditorDocument()->outlineModel(), &QmlOutlineModel::updated,
            this, &QmlJSOutlineWidget::modelUpdated);
}
Example #11
0
void QPieModelMapper::setModel(QAbstractItemModel *model)
{
    if (model == 0)
        return;

    Q_D(QPieModelMapper);
    if (d->m_model) {
        disconnect(d->m_model, 0, d, 0);
    }

    d->m_model = model;
    d->initializePieFromModel();
    //    connect signals from the model
    connect(d->m_model, SIGNAL(modelReset()), d, SLOT(initializePieFromModel()));
    connect(d->m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), d, SLOT(modelUpdated(QModelIndex,QModelIndex)));
    connect(d->m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), d, SLOT(modelRowsAdded(QModelIndex,int,int)));
    connect(d->m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), d, SLOT(modelRowsRemoved(QModelIndex,int,int)));
    connect(d->m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), d, SLOT(modelColumnsAdded(QModelIndex,int,int)));
    connect(d->m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), d, SLOT(modelColumnsRemoved(QModelIndex,int,int)));
    connect(d->m_model, SIGNAL(destroyed()), d, SLOT(handleModelDestroyed()));
}
void MainWindow::setBendingManipulator(int index)
{
    bendingManipulator = standardBendingManipulators->get(index);

    switch (index) {
        case 0:
            ui->cantiliver->setChecked(true);
            bendingManipulator->type = 0;
            break;
        case 1:
            ui->simplySupported->setChecked(true);
            bendingManipulator->type = 1;
            break;
        case 2:
            ui->mixedSupported->setChecked(true);
            bendingManipulator->type = 2;
            break;
    }

    emit modelUpdated();
}
void MainWindow::setMaterial(int index)
{
    beam->SetMaterial(standardMaterials.get(index));
    ui->material->setCurrentIndex(index);
    emit modelUpdated();
}
void MainWindow::setLoadValue(double loadValue)
{
    load->setLoadValue(loadValue);
    ui->loadValue->setValue(loadValue/10);
    emit modelUpdated();
}
void MainWindow::onCrossSectionUpdated()
{
    emit modelUpdated();
}
Example #16
0
void QmlJSOutlineWidget::setShowBindings(bool showBindings)
{
    m_filterModel->setFilterBindings(!showBindings);
    modelUpdated();
    updateSelectionInTree(m_editor->outlineModelIndex());
}