Ejemplo n.º 1
0
void FrmCatch::previewRow(QModelIndex index)
{
    emit blockCatchUISignals(true);

    if (!this->groupDetails->isVisible())
        this->groupDetails->setVisible(true);

    emit lockControls(true,m_lWidgets);
    buttonBox->button(QDialogButtonBox::Apply)->hide();

    QModelIndex idx=viewCatch->index(index.row(),0);
    if (!idx.isValid()){
        emit showError (tr("Could not preview this catch!"));
        return;
    }

    QString id=idx.data().toString();

    tCatch->setFilter(tr("Sampled_Catch.ID=")+id);
    if (tCatch->rowCount()!=1)
        return;

    mapper1->toLast();

    //pushNext->setEnabled(true);
    emit blockCatchUISignals(false);
}
Ejemplo n.º 2
0
bool FrmCatch::reallyApply()
{
    bool bError=false;

    if (mapper1->submit()) {
        bError=!
               tCatch->submitAll();
        if (bError) {
            if (tCatch->lastError().type()!=QSqlError::NoError)
                emit showError(tCatch->lastError().text());
            else
                emit showError(tr("Could not write operation in the database!"));
        }
    } else bError=true;

    buttonBox->button(QDialogButtonBox::Apply)->setEnabled(bError);

    emit lockControls(!bError,m_lWidgets);
    if (!bError) {
        buttonBox->button(QDialogButtonBox::Apply)->hide();
    } else {
        buttonBox->button(QDialogButtonBox::Apply)->show();
    }

    if (!bError)
        return afterApply();

    return false;
}
Ejemplo n.º 3
0
int GenericTab::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: lockControls((*reinterpret_cast< bool(*)>(_a[1])),(*reinterpret_cast< QList<QWidget*>(*)>(_a[2]))); break;
        case 1: forward((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 2: gotPar(); break;
        case 3: navigate((*reinterpret_cast< const bool(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break;
        case 4: hideFrameDetails((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 5: showFrameDetails((*reinterpret_cast< const FrmFrameDetails::Mode(*)>(_a[1])),(*reinterpret_cast< const FrmFrameDetails::Persistence(*)>(_a[2])),(*reinterpret_cast< Sample*(*)>(_a[3])),(*reinterpret_cast< QList<int>(*)>(_a[4])),(*reinterpret_cast< const FrmFrameDetails::Options(*)>(_a[5]))); break;
        case 6: showFrameDetails((*reinterpret_cast< const FrmFrameDetails::Mode(*)>(_a[1])),(*reinterpret_cast< const FrmFrameDetails::Persistence(*)>(_a[2])),(*reinterpret_cast< Sample*(*)>(_a[3])),(*reinterpret_cast< QList<int>(*)>(_a[4]))); break;
        case 7: showFrameDetails((*reinterpret_cast< const FrmFrameDetails::Mode(*)>(_a[1])),(*reinterpret_cast< const FrmFrameDetails::Persistence(*)>(_a[2])),(*reinterpret_cast< Sample*(*)>(_a[3]))); break;
        case 8: showStatus((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 9: showError((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< const bool(*)>(_a[2]))); break;
        case 10: showError((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 11: fillHeader((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 12: onShowForm(); break;
        case 13: { bool _r = next();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 14: goBack(); break;
        case 15: goForward(); break;
        case 16: onLockControls((*reinterpret_cast< bool(*)>(_a[1])),(*reinterpret_cast< QList<QWidget*>(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 17;
    }
    return _id;
}
Ejemplo n.º 4
0
void FrmCatch::uI4NewRecord()
{
    if (!this->groupDetails->isVisible())
        this->groupDetails->setVisible(true);

    emit lockControls(false,m_lWidgets);

    textComments->clear();

    //TODO: remove this initialization later, when we put the BL layer
    catchInputCtrl->cmbBoxUnits->setCurrentIndex(this->catchInputCtrl->cmbBoxUnits->findText(
        qApp->translate("null_replacements", strNa)));

    catchInputCtrl->cmbUnitUnits->setCurrentIndex(this->catchInputCtrl->cmbUnitUnits->findText(
        qApp->translate("null_replacements", strNa)));

    catchInputCtrl->cmbWeightUnits->setCurrentIndex(this->catchInputCtrl->cmbWeightUnits->findText(
        qApp->translate("null_replacements", strNa)));

    cmbUnits->setCurrentIndex(cmbUnits->findText(
        qApp->translate("null_replacements", strNa)));

    buttonBox->button(QDialogButtonBox::Apply)->show();
    buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true);
}
Ejemplo n.º 5
0
void InteractionHandler::orbitDelta(const glm::quat& rotation)
{
    lockControls();

    // the camera position
    psc relative = _camera->position();

    // should be changed to something more dynamic =)
    psc origin;
    if (_focusNode) {
        origin = _focusNode->worldPosition();
    }

    psc relative_origin_coordinate = relative - origin;
    //glm::mat4 rotation_matrix = glm::mat4_cast(glm::inverse(rotation));
    //relative_origin_coordinate = relative_origin_coordinate.vec4() * glm::inverse(rotation);
    relative_origin_coordinate = glm::inverse(rotation) * relative_origin_coordinate.vec4();
    relative = relative_origin_coordinate + origin;
    glm::mat4 la = glm::lookAt(_camera->position().vec3(), origin.vec3(), glm::rotate(rotation, glm::vec3(_camera->lookUpVectorCameraSpace())));
    
    unlockControls();
    
    _camera->setPosition(relative);
    //camera_->rotate(rotation);
    //camera_->setRotation(glm::mat4_cast(rotation));

    
    _camera->setRotation(glm::quat_cast(la));
    //camera_->setLookUpVector();

    
}
Ejemplo n.º 6
0
void FrmCatch::editFinished()
{
    setPreviewQuery();
    pushEdit->setChecked(false);
    pushNew->setEnabled(!pushEdit->isChecked());
    pushRemove->setEnabled(!pushEdit->isChecked());
    emit lockControls(true,m_lWidgets);
}
void FrmMinorStrata::editFinished()
{
    setPreviewQuery();
    pushEdit->setChecked(false);
    pushNew->setEnabled(!pushEdit->isChecked());
    pushRemove->setEnabled(!pushEdit->isChecked());
    toolButton->setEnabled(false);
    emit lockControls(true,m_lWidgets);
}
Ejemplo n.º 8
0
bool FrmCell::reallyApply()
{
        bool bError=false;
            if (!bError){
                if (mapper1->submit()){
                    bError=!
                        tSampCell->submitAll();
                    if (bError){
                        if (tSampCell->lastError().type()!=QSqlError::NoError)
                            emit showError(tSampCell->lastError().text());
                        else
                            emit showError(tr("Could not write cell in the database!"));
                    }//mapper1->toLast();
                }else bError=true;
            }
        //}
        buttonBox->button(QDialogButtonBox::Apply)->setEnabled(bError);

        emit lockControls(!bError,m_lWidgets);
        if (!bError){
            buttonBox->button(QDialogButtonBox::Apply)->hide();
        }else{
            buttonBox->button(QDialogButtonBox::Apply)->show();
        }

        if (!bError){
            if (!afterApply()) bError=false;
            else{

                toolButton->setEnabled(true);

                updateSample();

                QToolTip::showText(toolButton->mapToGlobal(toolButton->pos()), 
                    tr("You have just initialized a cell!\n Now before starting to introduce information, ")
                    + tr("take a moment to have a look at the frame.\n ")
                    + tr("If you wish to do any temporary changes, *please do it NOW*! ")
                    , toolButton);

                //lets disable next till we review the frame
                pushNext->setEnabled(false);
                pushPrevious->setEnabled(false);

            }
        }
        return !bError;
}
Ejemplo n.º 9
0
bool FrmCatch::onButtonClick(QAbstractButton* button)
{
    if ( buttonBox->buttonRole(button) == QDialogButtonBox::RejectRole)
    {
        this->groupDetails->hide();
        this->tCatch->revertAll();
        return true;

    } else if (buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole){

        bool bError=false;

        if (mapper1->submit()){
            bError=!
                tCatch->submitAll();
                if (bError){
                    if (tCatch->lastError().type()!=QSqlError::NoError)
                        emit showError(tCatch->lastError().text());
                    else
                        emit showError(tr("Could not write operation in the database!"));
                }
        }else bError=true;

        button->setEnabled(bError);

        emit lockControls(!bError,m_lWidgets);
        if (!bError){
            buttonBox->button(QDialogButtonBox::Apply)->hide();
        }else{
            buttonBox->button(QDialogButtonBox::Apply)->show();
        }

        if (!bError)
            return afterApply();

    }

    return false;
}
Ejemplo n.º 10
0
void InteractionHandler::distanceDelta(const PowerScaledScalar& distance, size_t iterations)
{
    if (iterations > 5)
        return;
    //assert(this_);
    lockControls();
        
    psc relative = _camera->position();
    const psc origin = (_focusNode) ? _focusNode->worldPosition() : psc();
    
    unlockControls();

    psc relative_origin_coordinate = relative - origin;
    const glm::vec3 dir(relative_origin_coordinate.direction());
    glm::vec3 newdir = dir * distance[0];

    relative_origin_coordinate = newdir;
    relative_origin_coordinate[3] = distance[1];
    relative = relative + relative_origin_coordinate;

    relative_origin_coordinate = relative - origin;
    if (relative_origin_coordinate.vec4().x == 0.f && relative_origin_coordinate.vec4().y == 0.f && relative_origin_coordinate.vec4().z == 0.f)
        // TODO: this shouldn't be allowed to happen; a mechanism to prevent the camera to coincide with the origin is necessary (ab)
        return;

    newdir = relative_origin_coordinate.direction();

    // update only if on the same side of the origin
    if (glm::angle(newdir, dir) < 90.0f) {
        _camera->setPosition(relative);
    }
    else {
        PowerScaledScalar d2 = distance;
        d2[0] *= 0.75f;
        d2[1] *= 0.85f;
        distanceDelta(d2, iterations + 1);
    }
}
Ejemplo n.º 11
0
void FrmFrame::apply()
{
    bool bError=false;

    //We call a stored procedure to see if there are GLS available outside the bin
     QSqlQuery query;
     query.setForwardOnly(true);

     int id= cmbPrexistent->model()->index(cmbPrexistent->currentIndex(),0).data().toInt();

    int n=0;
    query.prepare("{CALL spCountGLS4Frame(?,?)}");
    query.bindValue(0,id);
    query.bindValue("Number",n,QSql::Out);

     if (!query.exec()){
         emit showError(query.lastError().text());
         bError=true;;
     }

    n = query.boundValue("Number").toInt();

    if (n<1){
        emit showError(tr("There are no Group of Landing Sites for this frame!"));
        bError=true;
    }else{

        //First insert the dates...
        if (!mapperStartDt->submit() || !mapperEndDt->submit()){
            if (m_tDateTime->lastError().type()!=QSqlError::NoError)
                emit showError(m_tDateTime->lastError().text());
            else
                emit showError(tr("Could not submit mapper!"));
            bError=true;
        }
        else{
            if (!m_tDateTime->submitAll()){
                if (m_tDateTime->lastError().type()!=QSqlError::NoError)
                    emit showError(m_tDateTime->lastError().text());
                else
                    emit showError(tr("Could not write DateTime in the database!"));

                bError=true;
            }
        }

        while(m_tDateTime->canFetchMore())
            m_tDateTime->fetchMore();

        mapperStartDt->setCurrentIndex(m_tDateTime->rowCount()-2);
        mapperEndDt->setCurrentIndex(m_tDateTime->rowCount()-1);

        int startIdx=mapperStartDt->currentIndex();
        int endIdx=mapperEndDt->currentIndex();

        if (bError) {
            emit showError(tr("Could not create dates in the database!"));
        }else{

        //Now insert the record
        while(tFrameTime->canFetchMore())
            tFrameTime->fetchMore();

        tFrameTime->insertRow(tFrameTime->rowCount());
        QModelIndex idx=tFrameTime->index(tFrameTime->rowCount()-1,1);//id frame
        if (idx.isValid()){
                int idFrame;
                if (getCurrentFrame(idFrame)){
                    tFrameTime->setData(idx,idFrame);
                    QModelIndex idx=tFrameTime->index(tFrameTime->rowCount()-1,2);//start dt
                    if (idx.isValid()){
                        int idStart;
                        if (getDtId(startIdx,idStart)){
                            tFrameTime->setData(idx,idStart);
                            idx=tFrameTime->index(tFrameTime->rowCount()-1,3);//end dt
                            if (idx.isValid()){
                                int idEnd;
                                if (getDtId(endIdx,idEnd)){
                                    tFrameTime->setData(idx,idEnd);
                                }else bError=true;
                            }
                        }else bError=true;
                    }else bError=true;
                }else bError=true;
            }else bError=true;
        }
        bError=!tFrameTime->submitAll();
    }

    if (!bError){
        QList<QWidget*> lWidgets;
        lWidgets << this->groupPhysical;
        lWidgets << this->groupTime;
        emit lockControls(true,lWidgets);
    }else{
        if (tFrameTime->lastError().type()!=QSqlError::NoError)
            emit showError(tFrameTime->lastError().text());
    }

    pushNext->setEnabled(!bError);
    pushApply->setEnabled(bError);

    if (!bError)
    {
        emit showStatus(tr("Record successfully inserted in the database!"));
        m_submitted=true;

        while(tFrameTime->canFetchMore())
            tFrameTime->fetchMore();

        m_curFrameTime=tFrameTime->rowCount()-1;
        updateSample();//update sample here, because of the save
    }
}
Ejemplo n.º 12
0
bool FrmTrip::reallyApply()
{
    bool bError=false;

    if (!listZones->selectionModel()->hasSelection()){
        emit showError(tr("You must select one or more zones for this trip!"));
        bError=true;
    }else{

        if (!listGears->selectionModel()->hasSelection()){
            emit showError(tr("You must select one or more gears for this trip!"));
            bError=true;
        }else{

            //First insert the dates...
            if (!mapperStartDt->submit() 
                || !mapperEndDt->submit()){
                if (m_tDateTime->lastError().type()!=QSqlError::NoError)
                    emit showError(m_tDateTime->lastError().text());
                else
                    emit showError(tr("Could not submit mapper!"));
                bError=true;
            }
            else{
                if (!m_tDateTime->submitAll()){
                    if (m_tDateTime->lastError().type()!=QSqlError::NoError)
                        emit showError(m_tDateTime->lastError().text());
                    else
                        emit showError(tr("Could not write DateTime in the database!"));

                    bError=true;
                }
            }

            while(m_tDateTime->canFetchMore())
                m_tDateTime->fetchMore();

            int startIdx=m_tDateTime->rowCount()-2;
            int endIdx=m_tDateTime->rowCount()-1;

            mapperStartDt->setCurrentIndex(startIdx);
            mapperEndDt->setCurrentIndex(endIdx);

            if (bError) {
                emit showError(tr("Could not create dates in the database!"));
            }else{

                int idStart;
                if (getDtId(startIdx,idStart)){
                    QModelIndex idxStart=tTrips->index(tTrips->rowCount()-1,2);
                    if (idxStart.isValid()){
                        tTrips->setData(idxStart,idStart);
                    }else bError=true;
                }else bError=true;

                int idEnd;
                if (getDtId(endIdx,idEnd)){
                    QModelIndex idxEnd=tTrips->index(tTrips->rowCount()-1,3);
                    if (idxEnd.isValid()){
                        tTrips->setData(idxEnd,idEnd);
                    }else bError=true;
                }else bError=true;

            if (mapper1->submit()){
                bError=!
                        tTrips->submitAll();
                if (bError){
                        if (tTrips->lastError().type()!=QSqlError::NoError)
                            emit showError(tTrips->lastError().text());
                        else
                            emit showError(tr("Could not write trip in the database!"));
                }else{
                    QModelIndex idd=tTrips->index(tTrips->rowCount()-1,0);

                    //multimodel for gears
                    multiModelI->setParentId(idd.data().toInt());
                    QString strError;
                    if (!multiModelI->list2Model(strError)){
                        emit showError(strError);
                        bError=true;
                    }
                    //multimodel for zones
                    multiModelI2->setParentId(idd.data().toInt());
                    if (!multiModelI2->list2Model(strError)){
                        emit showError(strError);
                        bError=true;
                    }

                }
            }
            }
        }
    }
    buttonBox->button(QDialogButtonBox::Apply)->setEnabled(bError);

    emit lockControls(!bError,m_lWidgets);
    if (!bError){
        buttonBox->button(QDialogButtonBox::Apply)->hide();
    }else{
        buttonBox->button(QDialogButtonBox::Apply)->show();
    }

    if (!bError)
        return afterApply();

    return false;
}
Ejemplo n.º 13
0
bool FrmOperation::reallyApply()
{
        bool bError=false;

        if (!listCategories->selectionModel()->hasSelection()){
            emit showError(tr("You must select one or more commercial categories for this trip!"));
            bError=true;
        }else{

            //First insert the dates...
            if (!mapperStartDt->submit() 
                || !mapperEndDt->submit()){
                if (m_tDateTime->lastError().type()!=QSqlError::NoError)
                    emit showError(m_tDateTime->lastError().text());
                else
                    emit showError(tr("Could not submit mapper!"));
                bError=true;
            }
            else{
                if (!m_tDateTime->submitAll()){
                    if (m_tDateTime->lastError().type()!=QSqlError::NoError)
                        emit showError(m_tDateTime->lastError().text());
                    else
                        emit showError(tr("Could not write DateTime in the database!"));

                    bError=true;
                }
            }

            while(m_tDateTime->canFetchMore())
                m_tDateTime->fetchMore();

            int startIdx=m_tDateTime->rowCount()-2;
            int endIdx=m_tDateTime->rowCount()-1;

            mapperStartDt->setCurrentIndex(startIdx);
            mapperEndDt->setCurrentIndex(endIdx);

            if (bError) {
                emit showError(tr("Could not create dates in the database!"));
            }else{

                int idStart;
                if (getDtId(startIdx,idStart)){
                    QModelIndex idxStart=tOperations->index(tOperations->rowCount()-1,2);
                    if (idxStart.isValid()){
                        tOperations->setData(idxStart,idStart);
                    }else bError=true;
                }else bError=true;

                int idEnd;
                if (getDtId(endIdx,idEnd)){
                    QModelIndex idxEnd=tOperations->index(tOperations->rowCount()-1,3);
                    if (idxEnd.isValid()){
                        tOperations->setData(idxEnd,idEnd);
                    }else bError=true;
                }else bError=true;

            if (mapper1->submit()){
                bError=!
                    tOperations->submitAll();
                    if (bError){
                        if (tOperations->lastError().type()!=QSqlError::NoError)
                            emit showError(tOperations->lastError().text());
                        else
                            emit showError(tr("Could not write operation in the database!"));
                    }else{
                        //Comiting Sampled_Fishing_Operations_Categories
                        QModelIndex idd=tOperations->index(tOperations->rowCount()-1,0);
                        multiModelI->setParentId(idd.data().toInt());
                        QString strError;
                        if (!multiModelI->list2Model(strError)){
                            emit showError(tr("Could not associate commercial categories to this fishing operation!"));
                            bError=true;
                        }

                    }
            }

            }
        }
        //button->setEnabled(bError);
        buttonBox->button(QDialogButtonBox::Apply)->setEnabled(bError);

        emit lockControls(!bError,m_lWidgets);
        if (!bError){
            buttonBox->button(QDialogButtonBox::Apply)->hide();
        }else{
            buttonBox->button(QDialogButtonBox::Apply)->show();
        }

        if (!bError)
            return afterApply();

    return false;
}
Ejemplo n.º 14
0
void InteractionHandler::orbit(const float &dx, const float &dy, const float &dz, const float &dist){

    lockControls();
    
    glm::vec3 cameraUp = glm::normalize((glm::inverse(_camera->viewRotationMatrix()) * glm::vec4(_camera->lookUpVectorCameraSpace(), 0))).xyz();
    glm::vec3 cameraRight = glm::cross(glm::vec3(_camera->viewDirectionWorldSpace()), cameraUp);

    glm::mat4 transform;
    transform = glm::rotate(glm::radians(dx * 100.f), cameraUp) * transform;
    transform = glm::rotate(glm::radians(dy * 100.f), cameraRight) * transform;
    transform = glm::rotate(glm::radians(dz * 100.f), glm::vec3(_camera->viewDirectionWorldSpace())) * transform;

    //get "old" focus position 
        
    psc camPos = _camera->position();
    psc focusPos = _camera->focusPosition();
    float distToFocusNodeCenter = (focusPos - camPos).length().lengthf();
    float focusNodeBounds = _focusNode ? _focusNode->boundingSphere().lengthf() : 0.f;

    float speedFactor = distToFocusNodeCenter - 0.098*focusNodeBounds;
        
    float rotationSpeed = glm::min(0.00001f * speedFactor, 100.0f);
    float zoomSpeed = glm::min(0.0000001f * speedFactor, 1.0f);
    float rollSpeed = 100.0f;
    

    glm::mat4 transform;
    transform = glm::rotate(glm::radians(dx * rotationSpeed), cameraUp) * transform;
    transform = glm::rotate(glm::radians(dy * rotationSpeed), cameraRight) * transform;
    transform = glm::rotate(glm::radians(dz * rollSpeed), _camera->viewDirection()) * transform;

    
    
    
    //// get camera position 
    //psc relative = _camera->position();

    // get camera position (UNSYNCHRONIZED)
    psc relative = _camera->unsynchedPosition();

    //get relative vector
    psc relative_focus_coordinate = relative - focusPos;
    //rotate relative vector
    relative_focus_coordinate = glm::inverse(transform) * relative_focus_coordinate.vec4();
    
    //get new new position of focus node
    psc origin;
    if (_focusNode) {
        origin = _focusNode->worldPosition();
    }

    //new camera position
    relative = origin + relative_focus_coordinate;     


    psc target = relative + relative_focus_coordinate * dist * zoomSpeed;

    //don't fly into objects
    if ((target - origin).length() < focusNodeBounds){
        //target = relative;
    }

    unlockControls();

    
    _camera->setFocusPosition(origin);
    _camera->setPosition(target);
    _camera->rotate(glm::quat_cast(transform));
    
}