Пример #1
0
bool AgentObserverMap::decode(QDataStream &in, TypesOfSubjects subject)
{
    bool ret = false;
    QString msg;
    in >> msg;

    // qDebug() << msg.split(PROTOCOL_SEPARATOR, QString::SkipEmptyParts);

    Attributes * attrib = 0;
    
    if (subject == TObsTrajectory)
    {
        attrib = getMapAttributes()->value("trajectory");
    }
    else
    {
		//@RAIAN: Neighborhood
		if(subject == TObsCell)
		{
			attrib = getMapAttributes()->value(className);
		}
		//@RAIAN: FIM
		else
		{
            // // ((subjectType == TObsAgent) || (subjectType == TObsAutomaton))
            // attrib = getMapAttributes()->value("currentState" + className);

            foreach (Attributes *attr, getMapAttributes()->values())
            {
                if (attr->getClassName() == className)
                {
                    attrib = attr;
                    break;
                }
            }
        }
    }
    if (attrib)
    {
        if (cleanImage)
            attrib->clear();

        ret = getProtocolDecoder().decode(msg, *attrib->getXsValue(), *attrib->getYsValue());
        // getPainterWidget()->plotMap(attrib);
    }
    qApp->processEvents();
    return ret;
}
Пример #2
0
bool ObserverMap::draw(QDataStream &state)
{
    bool decoded = false;
    QString msg;
    state >> msg;

    QList<Attributes *> listAttribs = mapAttributes->values();
    Attributes * attrib = 0;

    connectTreeLayerSlot(false);
    for (int i = 0; i < listAttribs.size(); i++)
    {
        attrib = listAttribs.at(i);
        if (attrib->getType() == TObsCell)
        {
            attrib->clear();

            decoded = protocolDecoder->decode(msg, *attrib->getXsValue(), *attrib->getYsValue());
            if (decoded)
                painterWidget->plotMap(attrib);
        }
        qApp->processEvents();
    }

    connectTreeLayerSlot(true);

    // cria a legenda e exibe na tela
	//@RAIAN: Troquei esta comparacao porque nao estava criando a legenda da segunda camada (No meu caso, a vizinhanca)
    //if (/*decoded &&*/ legendWindow && (builtLegend < 1))
	if ((legendWindow) && (builtLegend < mapAttributes->size()))
    {
	//@RAIAN: FIM
        connectTreeLayerSlot(false);
        legendWindow->makeLegend();
        showLayerLegend();

        painterWidget->replotMap();
        connectTreeLayerSlot(true);

        // exibe o zoom de janela
        zoomWindow();
        builtLegend++;
    }

    return decoded;
}