//--------------------------------------------------------------------- void OverlayManager::destroyAllOverlayElementsImpl(ElementMap& elementMap) { ElementMap::iterator i; while ((i = elementMap.begin()) != elementMap.end()) { OverlayElement* element = i->second; // Get factory to delete FactoryMap::iterator fi = mFactories.find(element->getTypeName()); if (fi == mFactories.end()) { OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Cannot locate factory for element " + element->getName(), "OverlayManager::destroyAllOverlayElements"); } // remove from parent, if any OverlayContainer* parent; if ((parent = element->getParent()) != 0) { parent->_removeChild(element->getName()); } // children of containers will be auto-removed when container is destroyed. // destroy the element and remove it from the list fi->second->destroyOverlayElement(element); elementMap.erase(i); } }
void addXmlElements( TiXmlElement *rootElement, const ElementMap &elementMap, bool /*old*/) { TiXmlElement *matricesElement = new TiXmlElement("Matrices"); TiXmlElement *elementsElement = new TiXmlElement("Elements"); addElement(matricesElement, "LGEOTransform", "0,0,-25,0,-25,0,0,0,0,-25,0,0,0,0,0,1"); rootElement->LinkEndChild(matricesElement); for (ElementMap::const_iterator it = elementMap.begin(); it != elementMap.end(); it++) { const std::string &ldrawFilename = it->first; const Element &element = it->second; TiXmlElement *elementElement = addElement(elementsElement, "Element"); addElement(elementElement, "LDrawFilename", ldrawFilename); addElement(elementElement, "POVName", element.lgeoName); TiXmlElement *nameElement = addElement(elementElement, "POVName", element.lgeoName + "_clear"); nameElement->SetAttribute("Alternate", "Clear"); if (element.flags & 0x01) { nameElement = addElement(elementElement, "POVName", element.lgeoName + "_slope"); nameElement->SetAttribute("Texture", "Slope"); } addElement(elementElement, "Dependency", "LGDefs"); addElement(elementElement, "POVFilename", element.lgeoFilename); addElement(elementElement, "MatrixRef", "LGEOTransform"); } rootElement->LinkEndChild(elementsElement); }
void DataVisualizer::display(int index) { if (!mDB || !cbCharacteristic) return; int propertyIndex(cbCharacteristic->itemData(index).toInt()); if (propertyIndex < 0 || propertyIndex > Element::propertyCount()) return; // see if item should be drawn Element::Property p(Element::getProperty(propertyIndex)); Element::PropertyType type(Element::propertyType(p)); if (type == Element::COMPLEX_TYPE || type == Element::STRING_TYPE) { lblPlotType->setText(tr("[ Horizontal distances are <b>not</b> proportional to the values. ]")); } else { lblPlotType->setText(tr("[ Horizontal distances are proportional to the values. ]")); } // reset graphics scene SceneType scene(new QGraphicsScene()); SceneType oldScene(gvDisplay->scene()); gvDisplay->setScene(scene); if (oldScene) delete oldScene; ElementDatabase::Iterator begin = mDB->begin(); ElementDatabase::Iterator end = mDB->end(); ElementDatabase::Iterator it = begin; // copy elements to sorted container first typedef QMultiMap<Element::PropertyVariant, Element::Ptr> ElementMap; ElementMap elemMap; for(; it != end; it++) { Element::Ptr elem(it.value()); if (elem.isNull()) continue; Element::PropertyVariant prop = elem->propertyConst(p); boost::apply_visitor(PreparePropertyVariantForSorting(), prop); elemMap.insert(prop, elem); } // finally draw the elements qreal lastXPos = -1e10; // need an arbitrary small number ElementMap::const_iterator mapIter = elemMap.begin(); for(; mapIter != elemMap.end(); mapIter++) { draw(scene, lastXPos, mapIter.value(), propertyIndex); } // get scene bounding box, add a margin QRectF sceneBoundingBox(scene->itemsBoundingRect()); sceneBoundingBox.setWidth(sceneBoundingBox.width()+2*itemMargin); sceneBoundingBox.setHeight(sceneBoundingBox.height()+2*itemMargin); sceneBoundingBox.translate(-1.0*itemMargin, -1.0*itemMargin); scene->setSceneRect(sceneBoundingBox); gvDisplay->show(); adjustSize(); }
boost::any QtChai_ElementRegistrar::updateGUIElementRegister() { assert(chai_); /// /// then, it is necessary to register the widgets in the /// global context /// //FIXME this return value it is not used /// for all recognized widgets, add a new value to the map std::map<std::string, GenericAbstractionResult *> values; ElementMap elementMap = context_->elementAbstractor->getElements(); ElementMap::const_iterator itelement = elementMap.begin(); for (;itelement!=elementMap.end();itelement++) { boost::any ob=itelement->second->object(); //std::cout<<"Registrando en CHAISCRIPT "<<itelement->first<<std::endl; if (ob.type()==typeid(QLineEdit *)) { chai_->add(chaiscript::var(boost::any_cast<QLineEdit *>(ob)), itelement->first); }else if (ob.type()==typeid(QSpinBox *)) { chai_->add(chaiscript::var(boost::any_cast<QSpinBox *>(ob)), itelement->first); }else if (ob.type()==typeid(QComboBox *)) { chai_->add(chaiscript::var(boost::any_cast<QComboBox *>(ob)), itelement->first); }else if (ob.type()==typeid(QPushButton *)) { chai_->add(chaiscript::var(boost::any_cast<QPushButton *>(ob)), itelement->first); }else if (ob.type()==typeid(QCheckBox *)) { chai_->add(chaiscript::var(boost::any_cast<QCheckBox *>(ob)), itelement->first); }else if (ob.type()==typeid(QRadioButton *)) { chai_->add(chaiscript::var(boost::any_cast<QRadioButton *>(ob)), itelement->first); } else{ continue; } values[itelement->first] = itelement->second; } /// return the values map boost::any result = values; return result; }