Пример #1
0
DataClass::DataClass()
{
m_ActiveShip = new ShipData(QString());
// m_ActiveShip->init();
m_ActiveCity = 0;
m_ActiveKontor = new KontorData();
m_ActiveChar = new Person();

m_CurrentMap = new Map();

addShip(*m_ActiveShip);
delete m_ActiveShip;
m_ActiveShip = &m_ShipList.first();

m_landingprocess.setStatus(Landing::NotActive);
connect(&calc_data_timer, SIGNAL(timeout()), this, SLOT(calcData()));
// singleplayer = true;
m_anbord = true;


}
Пример #2
0
void DisplayWidget::realTimeData()
{
    double time = QDateTime::currentDateTime().toMSecsSinceEpoch()/1000.0;
    
    //as fast as possible calc the data
    calcData();
            
    // remove data of lines that's outside visible range:
    m_graph_vorfahrtgew->removeDataBefore(time - 12);
    m_graph_vorfahrt->removeDataBefore(time - 12);
    m_graph_stop->removeDataBefore(time - 12);
    m_graph_parken->removeDataBefore(time - 12);
    m_graph_geradeaus->removeDataBefore(time - 12);    
    m_graph_kreuzung->removeDataBefore(time - 12);
    m_graph_fussgaenger->removeDataBefore(time - 12);;
    m_graph_kreisverkehr->removeDataBefore(time - 12);
    m_graph_ueberholverbot->removeDataBefore(time - 12);
    m_graph_verboteinfahrt->removeDataBefore(time - 12);    
    m_graph_einbahnstrasse->removeDataBefore(time - 12);
    // make key axis range scroll with the data (at a constant range size of 8):
    ui->customPlot->xAxis->setRange(time + 0.25, 8, Qt::AlignRight);
    ui->customPlot->replot();
}
Пример #3
0
//--------------------------------------------------
void ofPolyline::updateCache(bool bForceUpdate) const {
    if(bCacheIsDirty || bForceUpdate) {
        lengths.clear();
        angles.clear();
        rotations.clear();
        normals.clear();
        tangents.clear();
        area = 0;
        centroid2D.set(0, 0, 0);
        bCacheIsDirty = false;
        
        if(points.size() < 2) return;

        // area
        for(int i=0;i<(int)points.size()-1;i++){
            area += points[i].x * points[i+1].y - points[i+1].x * points[i].y;
        }
        area += points[points.size()-1].x * points[0].y - points[0].x * points[points.size()-1].y;
        area *= 0.5;

        
        // centroid
        // TODO: doesn't seem to work on all concave shapes
        for(int i=0;i<(int)points.size()-1;i++){
            centroid2D.x += (points[i].x + points[i+1].x) * (points[i].x*points[i+1].y - points[i+1].x*points[i].y);
            centroid2D.y += (points[i].y + points[i+1].y) * (points[i].x*points[i+1].y - points[i+1].x*points[i].y);
        }
        centroid2D.x += (points[points.size()-1].x + points[0].x) * (points[points.size()-1].x*points[0].y - points[0].x*points[points.size()-1].y);
        centroid2D.y += (points[points.size()-1].y + points[0].y) * (points[points.size()-1].x*points[0].y - points[0].x*points[points.size()-1].y);
        
        centroid2D.x /= (6*area);
        centroid2D.y /= (6*area);

        
        // per vertex cache
        lengths.resize(points.size());
        tangents.resize(points.size());
        angles.resize(points.size());
        normals.resize(points.size());
        rotations.resize(points.size());
        
        float angle;
        ofVec3f rotation;
        ofVec3f normal;
        ofVec3f tangent;

        float length = 0;
        for(int i=0; i<(int)points.size(); i++) {
            lengths[i] = length;

            calcData(i, tangent, angle, rotation, normal);
            tangents[i] = tangent;
            angles[i] = angle;
            rotations[i] = rotation;
            normals[i] = normal;
            
            length += points[i].distance(points[getWrappedIndex(i + 1)]);
        }
        
        if(isClosed()) lengths.push_back(length);
    }
}
tResult MarkerEvaluator::OnPinEvent(IPin *sourcePin, tInt eventCode, tInt nParam1, tInt nParam2, IMediaSample *mediaSample)
{
    if (eventCode != IPinEventSink::PE_MediaSampleReceived)
    {
        RETURN_NOERROR;
    }

    RETURN_IF_POINTER_NULL(mediaSample);

    logger.StartLog();

    if (sourcePin == &roadSignInput)
    {
        struct timeval tv;

        gettimeofday(&tv, NULL);

        unsigned long long msnew =
                (unsigned long long) (tv.tv_sec) * 1000 +
                (unsigned long long) (tv.tv_usec) / 1000;

        if (lastUpdate + 3000 < msnew)
        {
            signBuffer.clear();
        }
        lastUpdate = msnew;

        tInt16 signId = 0;
        tFloat32 signSize = 0;

        {
            __adtf_sample_read_lock_mediadescription(roadSignDescription, mediaSample, pCoderInput);

            pCoderInput->Get("i16Identifier", (tVoid *) &signId);
            pCoderInput->Get("f32Imagesize", (tVoid *) &signSize);
        }

        signBuffer.push_back(signId);
        if (signBuffer.size() > RANGE_DATASET)
        {
            calcData();
        }
    }
    else if (sourcePin == &getReadyInput)
    {
        tReadyModule::ReadyModuleEnum module;

        {
            __adtf_sample_read_lock_mediadescription(enumDescription, mediaSample, pCoder);
            pCoder->Get("tEnumValue", (tVoid *) &module);
        }

        if (tReadyModule::MarkerEvaluator == module)
        {
            logger.Log("Resetting.", false);

            signBuffer.clear();

            SendEnum(markerOutput, static_cast<tInt>(tRoadSign::NO_MATCH));
            SendValue(noOvertakingOutput, false);

            SendEnum(readyOutput, static_cast<tInt>(tReadyModule::MarkerEvaluator));
        }
    }

    logger.EndLog();

    RETURN_NOERROR;
}