void SchematicSceneBuilder::end_userdef_component( std::string name, std::map<std::string,std::string> props ) { int size = scene_->size(); QByteArray md5 = stack_.back().first->registerUserDef(*scene_); Component* component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::UserDefItemType)); component->setPath(SchematicScene::userDefPath(size)); component->addNodes(SchematicScene::userDefNodes(size)); component->setData(99, md5); QPointer<qsapecng::SchematicScene> smart(scene_); component->setData(101, qVariantFromValue(smart)); QPair< SchematicScene*, QList<QGraphicsItem*> > pair = stack_.pop(); items_.clear(); items_.append(pair.second); scene_ = pair.first; scene_->addSupportedItem(component, false); grid_coordinate(component, props); setup_properties(component, name, /* foo */ 0, /* foo */ false, /* foo */ props); mirror_and_rotate(component, props); adjust_label(component, props); items_.push_back(component); }
int main(int argc, char **argv) { struct sun_disklabel sl; int part, bf, of; off_t cylstart, cylsize; if (argc != 4) { usage(); return (1); } if (argv[1] == NULL || strlen(argv[1]) != 1 || (argv[1][0] < 'a' || argv[1][0] > 'h')) { usage(); return (1); } part = argv[1][0] - 'a'; if (argv[2] == NULL || argv[3] == NULL) { usage(); return (1); } bf = open(argv[2], O_RDWR); if (bf == -1) err(1, "open"); of = open(argv[3], O_RDONLY); if (of == -1) err(1, "open"); if (get_label(bf, &sl)) return (1); if (adjust_base(bf, &sl)) return (1); cylstart = cylindersize(bf, &sl); cylsize = cylindersize(of, &sl); if (append_osfile(bf, of)) return (1); if (adjust_base(bf, &sl)) return (1); if (adjust_label(bf, &sl, part, cylstart, cylsize)) return (1); close(bf); close(of); return (0); }
void SchematicSceneBuilder::add_quad_component( sapecng::abstract_builder::quad_component_type c_type, std::string name, double value, bool symbolic, unsigned int va, unsigned int vb, unsigned int vac, unsigned int vbc, std::map<std::string, std::string> props ) { if(!discard(props)) { Component* component = 0; switch(c_type) { case sapecng::abstract_builder::VCCS: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::VCCSItemType)); break; } case sapecng::abstract_builder::VCVS: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::VCVSItemType)); break; } case sapecng::abstract_builder::CCCS: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::CCCSItemType)); break; } case sapecng::abstract_builder::CCVS: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::CCVSItemType)); break; } case sapecng::abstract_builder::AO: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::OpAmplItemType)); break; } case sapecng::abstract_builder::n: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::TransformerItemType)); break; } case sapecng::abstract_builder::K: { component = static_cast<Component*>( SchematicScene::itemByType( SchematicScene::MutualInductanceItemType)); break; } default: break; } if(component) { scene_->addSupportedItem(component, false); grid_coordinate(component, props); setup_properties(component, name, value, symbolic, props); mirror_and_rotate(component, props); adjust_label(component, props); items_.push_back(component); } } }
void SchematicSceneBuilder::add_dual_component( sapecng::abstract_builder::dual_component_type c_type, std::string name, double value, bool symbolic, unsigned int va, unsigned int vb, std::map<std::string, std::string> props ) { if(!discard(props)) { Component* component = 0; switch(c_type) { case sapecng::abstract_builder::R: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::ResistorItemType)); break; } case sapecng::abstract_builder::G: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::ConductanceItemType)); break; } case sapecng::abstract_builder::L: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::InductorItemType)); break; } case sapecng::abstract_builder::C: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::CapacitorItemType)); break; } case sapecng::abstract_builder::V: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::VoltageSourceItemType)); break; } case sapecng::abstract_builder::I: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::CurrentSourceItemType)); break; } case sapecng::abstract_builder::VM: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::VoltmeterItemType)); break; } case sapecng::abstract_builder::AM: { component = static_cast<Component*>( SchematicScene::itemByType(SchematicScene::AmmeterItemType)); break; } default: break; } if(component) { scene_->addSupportedItem(component, false); grid_coordinate(component, props); setup_properties(component, name, value, symbolic, props); mirror_and_rotate(component, props); adjust_label(component, props); items_.push_back(component); } } }