void QucsTranscalc::slotSynthesize() { int status = -1; if (TransLineTypes[getTypeIndex()].line) status = TransLineTypes[getTypeIndex()].line->synthesize(); if (status == 0) statusBar()->showMessage(tr("Values are consistent.")); else statusBar()->showMessage(tr("Failed to converge!")); }
/* Updates the current choice of physical property selection. */ void QucsTranscalc::updateSelection () { int idx = getTypeIndex (); struct TransValue * val = TransLineTypes[idx].array[TRANS_PHYSICAL].item; for (int i = 0; i < TransMaxBox[TRANS_PHYSICAL]; i++) { if (TransLineTypes[idx].radio[i] != -1) { val->radio->setHidden(false); if (TransLineTypes[idx].radio[i] == 1) { val->radio->setDown (true); val->radio->setChecked (true); val->radio->setToolTip(tr("Selected for Calculation")); } else { val->radio->setDown (false); val->radio->setChecked (false); val->radio->setToolTip(tr("Check item for Calculation")); } val->radio->setDisabled (false); } else { val->radio->setHidden(true); val->radio->setDown (false); val->radio->setChecked (false); val->radio->setDisabled (true); } val++; } }
/* Updates the current result items. */ void QucsTranscalc::updateResultItems() { int idx = getTypeIndex (); struct TransResult * res = TransLineTypes[idx].result; for (int i = 0; i < MAX_TRANS_RESULTS; i++) { updateResultItem (res); res++; } }
/* Returns the property value specified by its name. */ struct TransValue * QucsTranscalc::findProperty (QString prop) { struct TransValue * val = NULL; for (int box = 0; box < MAX_TRANS_BOXES; box++) { val = TransLineTypes[getTypeIndex ()].array[box].item; for (int i = 0; val->name; i++) { if (prop == val->name) return val; val++; } } return NULL; }
void QucsTranscalc::slotRadioChecked(int id) { int idx = getTypeIndex (); for (int i = 0; i < TransMaxBox[TRANS_PHYSICAL]; i++) { if (TransLineTypes[idx].radio[i] != -1) { TransLineTypes[idx].radio[i] = 0; if (i == id) { TransLineTypes[idx].radio[i] = 1; } } } updateSelection (); }
/* Writes the transmission line values for the current modes into the given stream. */ void QucsTranscalc::saveMode(QTextStream& stream) { struct TransType * t = &TransLineTypes[getTypeIndex ()]; struct TransValue * val = NULL; stream << "<" << t->description << ">\n"; for (int box = 0; box < MAX_TRANS_BOXES; box++) { val = t->array[box].item; while (val->name) { stream << " " << val->name << " " << val->value << " " << val->units[val->unit] << "\n"; val++; } } stream << "</" << t->description << ">\n"; }
/* Updates the property items of the current mode. */ void QucsTranscalc::updateMode (void) { // go through each type of parameter category for (int box = 0; box < MAX_TRANS_BOXES; box++) { int last = 0, idx = getTypeIndex(); struct TransValue * val = TransLineTypes[idx].array[box].item; // update each property item for (int i = 0; i < TransMaxBox[box]; i++) { // fix uninitialized memory if (val->name == NULL) last++; if (last) { val->name = NULL; val->value = 0; val->tip = NULL; val->units[0] = NULL; } updatePropItem (val); val++; } } }
bool AssetBrowser::resourceList(char* buf, int max_size, Lumix::ResourceType type, float height) { static char filter[128] = ""; ImGui::FilterInput("Filter", filter, sizeof(filter)); ImGui::BeginChild("Resources", ImVec2(0, height)); for (auto& res : getResources(getTypeIndex(type))) { if (filter[0] != '\0' && strstr(res.c_str(), filter) == nullptr) continue; if (ImGui::Selectable(res.c_str(), false)) { Lumix::copyString(buf, max_size, res.c_str()); ImGui::EndChild(); return true; } } ImGui::EndChild(); return false; }
/* The function creates the property items for the given category of transmission line parameters. */ void QucsTranscalc::createPropItems (QGroupBox *parent, int box) { struct TransValue * val, * dup; int last = 0, idx = getTypeIndex (); val = TransLineTypes[idx].array[box].item; QGridLayout *boxGrid = new QGridLayout(); QButtonGroup * group = new QButtonGroup(); connect(group, SIGNAL(buttonPressed(int)), SLOT(slotRadioChecked(int))); boxGrid->setSpacing(2); parent->setLayout(boxGrid); // go through each parameter category for (int i = 0; i < TransMaxBox[box]; i++) { // fix uninitialized memory if (val->name == NULL) last++; if (last) { val->name = NULL; val->value = 0; val->tip = NULL; val->units[0] = NULL; } createPropItem (boxGrid, val, box, group); // publish the newly created widgets to the other transmission lines for (int _mode = 0; _mode < MAX_TRANS_TYPES; _mode++) { if (idx != _mode) { dup = & TransLineTypes[_mode].array[box].item[i]; dup->label = val->label; dup->lineedit = val->lineedit; dup->combobox = val->combobox; dup->radio = val->radio; //dup->value = val->value; } } val++; } }
/* Creates all the result items. */ void QucsTranscalc::createResultItems (QGroupBox * parent) { struct TransResult * res, * dup; int idx = getTypeIndex (); res = & TransLineTypes[idx].result[0]; QGridLayout *boxGrid = new QGridLayout(); boxGrid->setSpacing(2); parent->setLayout(boxGrid); for (int i = 0; i < MAX_TRANS_RESULTS; i++) { createResultItem (boxGrid, res); for (int _mode = 0; _mode < MAX_TRANS_TYPES; _mode++) { if (idx != _mode) { dup = & TransLineTypes[_mode].result[i]; dup->label = res->label; dup->value = res->value; } } res++; } }
// Saves the GUI values into internal data structures. void QucsTranscalc::storeValues (void) { struct TransType * t = &TransLineTypes[getTypeIndex ()]; struct TransValue * val; for (int box = 0; box < MAX_TRANS_BOXES; box++) { val = t->array[box].item; int i = 0; while (val->name) { getProperty (val->name); getUnit (val->name); if (box == TRANS_PHYSICAL) { if (val->radio->isEnabled()) { if (val->radio->isChecked()) t->radio[i] = 1; else t->radio[i] = 0; } else t->radio[i] = -1; } i++; val++; } } }
/** * Return a handler that maps the python type to a C++ type * @param object :: A pointer to a PyObject that represents the type * @returns A pointer to handler that can be used to instantiate a property */ const PropertyValueHandler & PropertyWithValueFactory::lookup(PyObject *const object) { // Check if object is array. const auto ptype = isArray(object); if (!ptype.empty()) { const PyArrayIndex &arrayIndex = getArrayIndex(); auto ait = arrayIndex.find(ptype); if (ait != arrayIndex.end()) { return *(ait->second); } } // Object is not array, so check primitive types const PyTypeIndex &typeIndex = getTypeIndex(); auto cit = typeIndex.find(object->ob_type); if (cit == typeIndex.end()) { std::ostringstream os; os << "Cannot create PropertyWithValue from Python type " << object->ob_type->tp_name << ". No converter registered in PropertyWithValueFactory."; throw std::invalid_argument(os.str()); } return *(cit->second); }
int operator ()(const T& t) { return getTypeIndex(t); }
AnyAtomicType::AtomicObjectType ATBooleanOrDerivedImpl::getPrimitiveTypeIndex() const { return getTypeIndex(); }
void QucsTranscalc::slotAnalyze() { if (TransLineTypes[getTypeIndex()].line) TransLineTypes[getTypeIndex()].line->analyze(); statusBar()->showMessage(tr("Values are consistent.")); }
// Returns the current textual mode. QString QucsTranscalc::getMode (void) { return TransLineTypes[getTypeIndex ()].description; }
/* Puts the given result into its widget. */ void QucsTranscalc::setResult (int line, const char * text) { struct TransResult * res; res = & TransLineTypes[getTypeIndex ()].result[line]; res->value->setText (text); }
int malAtomProperty(MalBlkPtr mb, InstrPtr pci) { str name; int tpe; (void)mb; /* fool compilers */ assert(pci != 0); name = getFunctionId(pci); tpe = getTypeIndex(getModuleId(pci), (int)strlen(getModuleId(pci)), TYPE_any); if (tpe < 0 || tpe >= GDKatomcnt || tpe >= MAXATOMS) return 0; assert(pci->fcn != NULL); switch (name[0]) { case 'd': if (idcmp("del", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomDel = (void (*)(Heap *, var_t *))pci->fcn; setAtomName(pci); return 1; } break; case 'c': if (idcmp("cmp", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomCmp = (int (*)(const void *, const void *))pci->fcn; BATatoms[tpe].linear = 1; setAtomName(pci); return 1; } break; case 'f': if (idcmp("fromstr", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomFromStr = (int (*)(const char *, int *, ptr *))pci->fcn; setAtomName(pci); return 1; } if (idcmp("fix", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomFix = (int (*)(const void *))pci->fcn; setAtomName(pci); return 1; } break; case 'h': if (idcmp("heap", name) == 0 && pci->argc == 1) { /* heap function makes an atom varsized */ BATatoms[tpe].size = sizeof(var_t); assert_shift_width(ATOMelmshift(ATOMsize(tpe)), ATOMsize(tpe)); BATatoms[tpe].align = sizeof(var_t); BATatoms[tpe].atomHeap = (void (*)(Heap *, size_t))pci->fcn; setAtomName(pci); return 1; } if (idcmp("hash", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomHash = (BUN (*)(const void *))pci->fcn; setAtomName(pci); return 1; } break; case 'l': if (idcmp("length", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomLen = (int (*)(const void *))pci->fcn; setAtomName(pci); return 1; } break; case 'n': if (idcmp("null", name) == 0 && pci->argc == 1) { ptr atmnull = ((ptr (*)(void))pci->fcn)(); BATatoms[tpe].atomNull = atmnull; setAtomName(pci); return 1; } if (idcmp("nequal", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomCmp = (int (*)(const void *, const void *))pci->fcn; setAtomName(pci); return 1; } break; case 'p': if (idcmp("put", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomPut = (var_t (*)(Heap *, var_t *, const void *))pci->fcn; setAtomName(pci); return 1; } break; case 's': if (idcmp("storage", name) == 0 && pci->argc == 1) { BATatoms[tpe].storage = (*(int (*)(void))pci->fcn)(); setAtomName(pci); return 1; } break; case 't': if (idcmp("tostr", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomToStr = (int (*)(str *, int *, const void *))pci->fcn; setAtomName(pci); return 1; } break; case 'u': if (idcmp("unfix", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomUnfix = (int (*)(const void *))pci->fcn; setAtomName(pci); return 1; } break; case 'r': if (idcmp("read", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomRead = (void *(*)(void *, stream *, size_t))pci->fcn; setAtomName(pci); return 1; } break; case 'w': if (idcmp("write", name) == 0 && pci->argc == 1) { BATatoms[tpe].atomWrite = (gdk_return (*)(const void *, stream *, size_t))pci->fcn; setAtomName(pci); return 1; } break; } return 0; }
void AssetBrowser::update() { PROFILE_FUNCTION(); auto* patch = m_editor.getEngine().getPatchFileDevice(); if ((patch && !Lumix::equalStrings(patch->getBasePath(), m_patch_base_path)) || (!patch && m_patch_base_path[0] != '\0')) { findResources(); } if (!m_is_update_enabled) return; bool is_empty; { Lumix::MT::SpinLock lock(m_changed_files_mutex); is_empty = m_changed_files.empty(); } while (!is_empty) { Lumix::Path path; { Lumix::MT::SpinLock lock(m_changed_files_mutex); path = m_changed_files.back(); m_changed_files.pop(); is_empty = m_changed_files.empty(); } char ext[10]; Lumix::PathUtils::getExtension(ext, Lumix::lengthOf(ext), path.c_str()); m_on_resource_changed.invoke(path, ext); Lumix::ResourceType resource_type = getResourceType(path.c_str()); if (!Lumix::isValid(resource_type)) continue; if (m_autoreload_changed_resource) m_editor.getEngine().getResourceManager().reload(path); char tmp_path[Lumix::MAX_PATH_LENGTH]; if (m_editor.getEngine().getPatchFileDevice()) { Lumix::copyString(tmp_path, m_editor.getEngine().getPatchFileDevice()->getBasePath()); Lumix::catString(tmp_path, path.c_str()); } if (!m_editor.getEngine().getPatchFileDevice() || !PlatformInterface::fileExists(tmp_path)) { Lumix::copyString(tmp_path, m_editor.getEngine().getDiskFileDevice()->getBasePath()); Lumix::catString(tmp_path, path.c_str()); if (!PlatformInterface::fileExists(tmp_path)) { int index = getTypeIndex(resource_type); m_resources[index].eraseItemFast(path); continue; } } char dir[Lumix::MAX_PATH_LENGTH]; char filename[Lumix::MAX_PATH_LENGTH]; Lumix::PathUtils::getDir(dir, sizeof(dir), path.c_str()); Lumix::PathUtils::getFilename(filename, sizeof(filename), path.c_str()); addResource(dir, filename); } m_changed_files.clear(); }