//--------------------------------------------------------------------- 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(); }
ECDiode::ECDiode(Circuit& ownerCircuit) : Component(ownerCircuit) { m_diode = new Diode(); ElementMap *map = new ElementMap(m_diode); m_elementMapList.append(map); m_pinMap.insert("n1", new ECNode(ownerCircuit, map->pin(0))); m_pinMap.insert("p1", new ECNode(ownerCircuit, map->pin(1))); DiodeSettings ds; // it will have the default properties that we use Property * i_s = new Property("I_S", Variant::Type::Double); i_s->setCaption(tr("Saturation Current")); i_s->setUnit("A"); i_s->setMinValue(1e-20); i_s->setMaxValue(1e-0); i_s->setValue(ds.I_S); i_s->setAdvanced(true); addProperty(i_s); Property *n = new Property("N", Variant::Type::Double); n->setCaption(tr("Emission Coefficient")); n->setMinValue(1.0); n->setMaxValue(1e1); n->setValue(ds.N); n->setAdvanced(true); addProperty(n); Property *v_b = new Property("V_B", Variant::Type::Double); v_b->setCaption(tr("Breakdown Voltage")); v_b->setUnit("V"); v_b->setMinAbsValue(1e-5); v_b->setMaxValue(1e10); v_b->setValue(ds.V_B); v_b->setAdvanced(true); addProperty(v_b); // createProperty( "R", Variant::Type::Double ); // property("R")->setCaption( i18n("Series Resistance") ); // property("R")->setUnit( QChar(0x3a9) ); // property("R")->setMinValue(1e-5); // property("R")->setMaxValue(1e0); // property("R")->setValue( ds.R ); // property("R")->setAdvanced(true); ownerCircuit.addComponent(this); }
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; }
void InternalCreatureType::reset() { experience = 0; defense = 0; armor = 0; canPushItems = false; canPushCreatures = false; staticAttackChance = 95; maxSummons = 0; targetDistance = 1; fleeHealth = 0; pushable = true; base_speed = 200; health = 100; health_max = 100; outfit.lookHead = 130; // Default man outfit.lookBody = 0; outfit.lookLegs = 0; outfit.lookFeet = 0; outfit.lookType = 0; outfit.lookTypeEx = 0; outfit.lookAddons = 0; corpseId = 0; mechanicImmunities = MECHANIC_NONE; damageImmunities = COMBAT_NONE; race = RACE_BLOOD; isSummonable = false; isIllusionable = false; isConvinceable = false; isAttackable = true; isHostile = true; isLureable = false; lightLevel = 0; lightColor = 0; manaCost = 0; summonList.clear(); lootItems.clear(); elementMap.clear(); spellAttackList.clear(); spellDefenseList.clear(); yellSpeedTicks = 0; yellChance = 0; voiceVector.clear(); changeTargetSpeed = 0; changeTargetChance = 0; //scriptList.clear(); }
//--------------------------------------------------------------------- void OverlayManager::destroyOverlayElementImpl(const String& instanceName, ElementMap& elementMap) { // Locate instance ElementMap::iterator ii = elementMap.find(instanceName); if (ii == elementMap.end()) { OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "OverlayElement with name " + instanceName + " not found.", "OverlayManager::destroyOverlayElement" ); } // Look up factory const String& typeName = ii->second->getTypeName(); FactoryMap::iterator fi = mFactories.find(typeName); if (fi == mFactories.end()) { OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Cannot locate factory for element type " + typeName, "OverlayManager::destroyOverlayElement"); } fi->second->destroyOverlayElement(ii->second); elementMap.erase(ii); }
//--------------------------------------------------------------------- bool OverlayManager::hasOverlayElementImpl(const String& name, ElementMap& elementMap) { ElementMap::iterator ii = elementMap.find(name); return ii != elementMap.end(); }