bool wxJigsawEditorDocument::AppendChildren(wxJigsawShape * dest, wxJigsawShapeGroup * group, size_t beforeIndex) { do { if(!dest || !group) break; if(dest->GetChildren().GetCount() < beforeIndex) break; wxJigsawShape * shape(NULL); wxJigsawShapeList::Node * firstNode = group->GetShapes().GetFirst(); wxJigsawShapeList::Node * lastNode = group->GetShapes().GetLast(); shape = firstNode->GetData(); if(!shape || !shape->GetHasBump()) break; shape = lastNode->GetData(); if(!shape || !shape->GetHasNotch()) break; size_t realIndex(beforeIndex); for(wxJigsawShapeList::Node * node = group->GetShapes().GetFirst(); node; node = group->GetShapes().GetFirst(), realIndex++) { wxJigsawShape * insertShape = node->GetData(); if(!insertShape) continue; group->Detach(insertShape); insertShape->SetParent(dest); dest->GetChildren().Insert(realIndex, insertShape); } GetGroups().DeleteObject(group); wxJigsawEditorView * view = wxDynamicCast(GetFirstView(), wxJigsawEditorView); RequestSizeRecalculation(); //UpdateLayout(view->GetScale()); return true; } while(false); return false; }
int EventTypeSet::addReal(const QString& t) { int index = realIndex(t); if (index>=0) return index; EventType* ct = EventType::knownRealType(t); if (!ct) ct = new EventType(t, t); // make it real ct->setRealIndex(); return add(ct); }
QVariant BtRemovePageTreeModel::data(const QModelIndex &i, int role) const { if (i.column() == 1) { QModelIndex realIndex(index(i.row(), 0, i.parent())); switch (role) { case Qt::DisplayRole: case Qt::ToolTipRole: return BtBookshelfTreeModel::data(realIndex, BtBookshelfModel::ModuleInstallPathRole); default: break; } } else { return BtBookshelfTreeModel::data(i, role); } return QVariant(); }
EventTypeMapping* EventTypeSet::createMapping(const QString& types) { // first check if there is enough space in the set int newCount = 0; int pos = 0, pos2, len = types.length(); while (1) { // skip space while((pos<len) && types[pos].isSpace()) pos++; pos2 = pos; while((pos2<len) && !types[pos2].isSpace()) pos2++; if (pos2 == pos) break; if (realIndex(types.mid(pos,pos2-pos)) == ProfileCostArray::InvalidIndex) newCount++; pos = pos2; } if (newCount+_realCount > ProfileCostArray::MaxRealIndex) { qDebug() << "EventTypeSet::createMapping: No space for " << newCount << " cost entries."; return 0; } EventTypeMapping* mapping = new EventTypeMapping(this); pos = 0; while (1) { // skip space while((pos<len) && types[pos].isSpace()) pos++; pos2 = pos; while((pos2<len) && !types[pos2].isSpace()) pos2++; if (pos2 == pos) break; mapping->append(addReal(types.mid(pos,pos2-pos))); pos = pos2; } return mapping; }
void fft_scope::mapSpectrumtoDisplay (int16_t level, int32_t freq) { int16_t i; double temp; int16_t index_1; // int16_t top_index, bottom_index; int32_t min_freq, max_freq; // index_1 = indexOf (freq); // // then compute the top and bottom of the segment in the // spectrumBuffer that is to be projected top_index = index_1 + (DSPFLOAT)(spectrumSize - index_1) / level; bottom_index = index_1 - (DSPFLOAT)index_1 / level; min_freq = frequencyFor (bottom_index); max_freq = frequencyFor (top_index); temp = ((DSPFLOAT)max_freq - min_freq) / displaySize; // // Note that top_index and bottom_index are abstract indices, // we defined realIndex for the actual mapping // Now we have to map the segment bottom-index .. top-index // to 0 .. displaySize // for the time being, we assume that // top_index - bottom_index + 1 >= displaySize DSPFLOAT ratio = ((DSPFLOAT)top_index - bottom_index + 1) / displaySize; // we extract for the i-th element of the displayvector // those parts of the spectrumvector that would contribute // to the value of the displayvector. Assumption is that // an accuracy of 10% is sufficient for (i = 0; i < displaySize; i ++) { DSPFLOAT sum = 0; int16_t j; for (j = 0; j < (int16_t)(5 * ratio); j ++) { int32_t a_index = (int32_t)floor ((5 * (bottom_index + i * ratio ) + j) / 5); sum += abs (spectrumBuffer [realIndex (a_index)]) / 5; } displayBuffer [i] = sum / temp; } for (i = 0; i < displaySize; i ++) X_axis [i] = (min_freq + (double)(i * temp)) / ((double)scale); }