bool AgentObserverMap::draw() { QList<Attributes *> attribList = getMapAttributes()->values(); Attributes *attrib = 0; qStableSort(attribList.begin(), attribList.end(), sortAttribByType); for(int i = 0; i < attribList.size(); i++) { attrib = attribList.at(i); if ( (attrib->getType() != TObsCell) && (attrib->getType() != TObsAgent) ) getPainterWidget()->plotMap(attrib); } //static int ss = 1; //for(int i = 0; i < attribList.size(); i++) //{ // //attrib = attribList.at(i); // //if ( (attrib->getType() != TObsCell) // // && (attrib->getType() != TObsAgent) ) // // attrib->getImage()->save("imgs/" + attrib->getName() + QString::number(ss) + ".png"); // qDebug() << attrib->getName() << ": " << getSubjectName(attrib->getType()); //} //ss++; return true; }
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; }
virtual void startElement(const String& ns, const String& local, const String& qname, const Attributes& atts) { try { if(ns == QC_T("http://www.google.com/ns")) {testPassed(QC_T("check ns uri"));} else {testFailed(QC_T("check ns uri"));} } catch(Exception& e) { uncaughtException(e.toString(), QC_T("check ns uri")); } try { if(local == QC_T("test")) {testPassed(QC_T("check local"));} else {testFailed(QC_T("check local"));} } catch(Exception& e) { uncaughtException(e.toString(), QC_T("check local")); } try { if(qname == QC_T("qc:test")) {testPassed(QC_T("check qname"));} else {testFailed(QC_T("check qname"));} } catch(Exception& e) { uncaughtException(e.toString(), QC_T("check qname")); } try { if(atts.getLength() == (1 + NamespaceAttributes)) {testPassed(QC_T("check atts"));} else {testFailed(QC_T("check atts"));} } catch(Exception& e) { uncaughtException(e.toString(), QC_T("check atts")); } try { if(atts.getType(0) == QC_T("CDATA")) {testPassed(QC_T("check att type"));} else {testFailed(QC_T("check att type"));} } catch(Exception& e) { uncaughtException(e.toString(), QC_T("check att type")); } }
void CVxmlSAXHandler::startElement( const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attrs ){ TTagAttributes iAttributes char* pTagName; TTagAttribute iAttr; //get Tag's name and Attributes pTagName = XMLString::transcode(localname); // cout<<"attrs:"<<endl; for(int i=0;i<attrs.getLength();i++) { //get the Attribute's infomation iAttr.pName = XMLString::transcode(attrs.getLocalName(i)); iAttr.pType = XMLString::transcode(attrs.getType(i)); iAttr.pValue = XMLString::transcode(attrs.getValue(i)); // add to attributes's vector in order to send to Vxml Builder iAttributes.push_back(iAttr); // cout<<"\tLocalName="<<XMLString::transcode(attrs.getLocalName(i)); // cout<<"\tType="<<XMLString::transcode(attrs.getType(i)); // cout<<"\tVaule="<<XMLString::transcode(attrs.getValue(i))<<endl; } // build the Module by pass the infomation to Vxml Builder m_iBuilder->StartModule(pTagName,iAttributes); // release the resource XMLString::release(&pTagName); for(int i=0;i<iAttributes.size();i++) { iAttr = iAttributes.at(i); XMLString::release(&iAttr.pName); XMLString::release(&iAttr.pAttrType); XMLString::release(&iAttr.pAttrValue); } return; }
void ObserverMap::showLayerLegend() { int layer = treeLayers->topLevelItemCount(); QTreeWidgetItem *parent = 0, *child = 0; Attributes *attrib = 0; QVector<ObsLegend> *leg = 0; for (int i = 0; i < layer; i++) { parent = treeLayers->topLevelItem(i); treeLayers->setItemExpanded(parent, true); attrib = mapAttributes->value(parent->text(0)); leg = attrib->getLegend(); if (parent->childCount() > 0) parent->takeChildren(); for (int j = 0; j < leg->size(); j++) { child = new QTreeWidgetItem(parent); child->setSizeHint(0, ICON_SIZE); child->setText(0, leg->at(j).getLabel()); QColor color = leg->at(j).getColor(); if (attrib->getType() == TObsNeighborhood) { child->setData(0, Qt::DecorationRole, legendWindow->color2PixmapLine(color, attrib->getWidth())); } else { if (!leg->at(j).getLabel().contains("mean")) child->setData(0, Qt::DecorationRole, legendWindow->color2Pixmap(color, ICON_SIZE)); else child->setData(0, Qt::DecorationRole, QString("")); } } } treeLayers->resizeColumnToContents(0); }
void SemanticsVisitor::visit(StructReferencingNode& sr) { sr.getVarRef()->accept(*this); if (sr.getVarRef()->getType() == 0) { // NOTICE use errorType sr.setType(0); // NOTICE by design, null attribute and error type is 0. } else { if (StructTypeDescriptor* structTypeDesc = dynamic_cast<StructTypeDescriptor*>(sr.getVarRef()->getType())) { try { Attributes* attributeRef = structTypeDesc->getSymbolTable().retrieveSymbol( sr.getField()->name()); sr.setType(attributeRef->getType()); } catch (std::runtime_error& e) { errorLog() << sr.getField()->name() << " is not a field of " << typeid(sr.getVarRef()).name() << "\n"; sr.setType(0); // NOTICE by design, null attribute and error type is 0. } } else { errorLog() << sr.getVarRef() << " does not name a struct.\n"; sr.setType(0); // NOTICE by design, null attribute and error type is 0. } } }
//============================================================================== void AttributesImpl::setAttributes(const Attributes& atts) { // // First, remove all entries from this collection // clear(); // // Then iterate through the passed Attributes collection, creating // a new Attribute for each one and adding it to our collection // for(size_t i = 0; i < atts.getLength(); ++i) { AutoPtr<Attribute> rpAttr = new Attribute(atts.getQName(i), atts.getValue(i), atts.getType(i)); if(!m_attributes.addAttribute(rpAttr.get())) { throw IllegalArgumentException(QC_T("attribute already exists")); } } }
// --------------------------------------------------------------------------- // SAX2SortAttributesFilter: Overrides of the SAX2XMLFilter interface // --------------------------------------------------------------------------- void SAX2SortAttributesFilter::startElement(const XMLCh* const uri, const XMLCh* const localname, const XMLCh* const qname, const Attributes& attributes) { AttrList sortedList(attributes.getLength()); for(XMLSize_t i=0;i<attributes.getLength();i++) { XMLSize_t j; for(j=0;j<sortedList.getLength();j++) { if(XMLString::compareString(sortedList.elementAt(j)->qName,attributes.getQName(i))>=0) break; } Attr* pClone=new Attr; pClone->qName = attributes.getQName(i); pClone->uri = attributes.getURI(i); pClone->localPart = attributes.getLocalName(i); pClone->value = attributes.getValue(i); pClone->attrType = attributes.getType(i); sortedList.insertElementAt(pClone, j); } SAX2XMLFilterImpl::startElement(uri, localname, qname, sortedList); }
void AttributesImpl::setAttributes(const Attributes& attributes) { if (&attributes != this) { int count = attributes.getLength(); _attributes.clear(); _attributes.reserve(count); for (int i = 0; i < count; i++) { addAttribute(attributes.getURI(i), attributes.getLocalName(i), attributes.getQName(i), attributes.getType(i), attributes.getValue(i)); } } }