InternalCollections::InternalCollections() { int datasize, levelnum=0; #ifdef USE_LIBZ data_ = (char *) malloc(BUFSIZE); if (data_ == NULL) abort(); datasize = BUFSIZE; uncompress ((unsigned char *) data_, (long unsigned int *) &datasize, level_data_, sizeof (level_data_)); data_ = (char *) realloc(data_, datasize); if (data_ == NULL) abort (); #else datasize = sizeof (level_data_); data_ = (char *) malloc(datasize); if (data_ == NULL) abort(); memcpy(data_, level_data_, datasize); #endif int start=0, end=0, name=0; enum {NAME, DATA} state=NAME; while (end < datasize) { switch (state) { case NAME: if (data_[end] == '\n') { data_[end] = '\0'; state = DATA; } end++; start = end; break; case DATA: if (isalpha(data_[end])) { // collections_.add(new LevelCollection(data_+start, end-start, data_+name, collection_save_id[levelnum])); add(new LevelCollection(QByteArray(data_+start, end-start), collectionName(levelnum), collection_save_id[levelnum])); //printf("Level found: '%s'\n", data_+name); levelnum++; name = end; state = NAME; } end++; break; default: Q_ASSERT(0); } } if (state == DATA) { // collections_.add(new LevelCollection(data_+start, end-start, data_+name, collection_save_id[levelnum])); add(new LevelCollection(QByteArray(data_+start, end-start), collectionName(levelnum), collection_save_id[levelnum])); //printf("***Level found: '%s'\n", data_+name); } //printf("numlevels: %d/%d\n", levelnum+1, collections_.size()); }
void QvisSubsetPanelWidget::ViewCollection(int id) { avtSILRestriction_p restriction = viewerProxy->GetPlotSILRestriction(); avtSILCollection_p collection = restriction->GetSILCollection(id); numCheckable = 0; numChecked = 0; tree->clear(); if(*collection != NULL) { tree->setEnabled(true); blockSignals(true); SetTitle(collection->GetCategory().c_str()); const avtSILNamespace *ns = collection->GetSubsets(); int numElems = ns->GetNumberOfElements(); avtSILRestrictionTraverser trav(restriction); for(int i = 0; i < numElems; ++i) { int setIdx = ns->GetElement(i); avtSILSet_p set = restriction->GetSILSet(setIdx); // Create an item for the set and set its checked value. CheckedState s = S2S(trav.UsesSetData(setIdx)); QString cname(set->GetName().c_str()); QvisSubsetPanelItem *item = new QvisSubsetPanelItem(tree, cname, s, setIdx); numCheckable++; if(s == CompletelyChecked) numChecked++; // Add all of the collections that come out of the set. Note that // they are added as uncheckable items. QvisSubsetPanelItem *cItem = NULL; const std::vector<int> &mapsOut = set->GetMapsOut(); for(size_t j = 0; j < mapsOut.size(); ++j) { int cIndex = mapsOut[j]; avtSILCollection_p c = restriction->GetSILCollection(cIndex); QString collectionName(c->GetCategory().c_str()); cItem = new QvisSubsetPanelItem(item, collectionName, cIndex); } } blockSignals(false); } EnableButtons(true); }
void MLPluginController::processFileFromCollection (MLSymbol action, const MLFile fileToProcess, const MLFileCollection& collection, int idx, int size) { MLSymbol collectionName(collection.getName()); if(action == "process") { if(collectionName.beginsWith(MLSymbol("convert_presets"))) { // add file action to queue FileAction f(action, fileToProcess, &collection, idx, size); PaUtil_WriteRingBuffer( &mFileActionQueue, &f, 1 ); } } }
void QvisSubsetPanelWidget::ViewSet(int id) { avtSILRestriction_p restriction = viewerProxy->GetPlotSILRestriction(); numCheckable = 0; numChecked = 0; tree->clear(); tree->setEnabled(true); avtSILSet_p current = restriction->GetSILSet(id); const std::vector<int> &mapsOut = current->GetMapsOut(); // Create a listview item with the name of the whole set. QString wholeName(current->GetName().c_str()); avtSILRestrictionTraverser trav(restriction); CheckedState s = S2S(trav.UsesSetData(id)); QvisSubsetPanelItem *item = new QvisSubsetPanelItem(tree, wholeName, s, id); numCheckable++; if(s == CompletelyChecked) numChecked++; QvisSubsetPanelItem *checkItem=NULL; // Add all of the collections that come out of the whole. for(size_t j = 0; j < mapsOut.size(); ++j) { // cIndex is the j'th collection coming from out of the whole. int cIndex = mapsOut[j]; // Create a new item under the whole and set its checked value. avtSILCollection_p collection = restriction->GetSILCollection(cIndex); QString collectionName(collection->GetCategory().c_str()); checkItem = new QvisSubsetPanelItem(item, collectionName, cIndex); } item->setExpanded(true); EnableButtons(true); }
void KColorTable::setColors(const QString &_collectionName) { QString collectionName(_collectionName); if (d->combo->currentText() != collectionName) { bool found = false; for (int i = 0; i < d->combo->count(); i++) { if (d->combo->itemText(i) == collectionName) { d->combo->setCurrentIndex(i); found = true; break; } } if (!found) { d->combo->addItem(collectionName); d->combo->setCurrentIndex(d->combo->count() - 1); } } // We must again find the file name of the palette from the eventual translation for (int i = 0; colorCollectionName[i].m_fileName; ++i) { if (collectionName == tr(colorCollectionName[i].m_displayName)) { collectionName = colorCollectionName[i].m_fileName; break; } } // // 2000-02-12 Espen Sand // The palette mode "i18n_namedColors" does not use the KColorCollection // class. In fact, 'mPalette' and 'cells' are 0 when in this mode. The reason // for this is maninly that KColorCollection reads from and writes to files // using "locate()". The colors used in "i18n_namedColors" mode comes from // the X11 diretory and is not writable. I don't think this fit in // KColorCollection. // if (!d->mPalette || d->mPalette->name() != collectionName) { if (collectionName == d->i18n_namedColors) { d->sv->hide(); d->mNamedColorList->show(); readNamedColor(); delete d->cells; d->cells = 0; delete d->mPalette; d->mPalette = 0; } else { d->mNamedColorList->hide(); d->sv->show(); delete d->cells; delete d->mPalette; d->mPalette = new KColorCollection(collectionName); int rows = (d->mPalette->count() + d->mCols - 1) / d->mCols; if (rows < 1) rows = 1; d->cells = new KColorCells(d->sv->viewport(), rows, d->mCols); d->cells->setShading(false); d->cells->setAcceptDrags(false); QSize cellSize = QSize(d->mMinWidth, d->mMinWidth * rows / d->mCols); d->cells->setFixedSize(cellSize); for (int i = 0; i < d->mPalette->count(); i++) { d->cells->setColor(i, d->mPalette->color(i)); } connect(d->cells, SIGNAL(colorSelected(int , const QColor&)), SLOT(slotColorCellSelected(int , const QColor&))); connect(d->cells, SIGNAL(colorDoubleClicked(int , const QColor&)), SLOT(slotColorCellDoubleClicked(int , const QColor&))); d->sv->setWidget(d->cells); d->cells->show(); //d->sv->updateScrollBars(); } } }