/*! * Insert the given function into the list of functions that iiOpen will * call to check a file at position [index] in the list. The format of the * function is * ^ int iiFormatCheck(ImodImageFile *inFile) */ void iiInsertCheckFunction(IIFileCheckFunction func, int index) { if (initCheckList()) return; if (index < ilistSize(sCheckList)) ilistInsert(sCheckList, &func, index); else ilistAppend(sCheckList, &func); }
/* * Functions for adding, removing, and looking up a file in the list */ static int addToOpenedList(ImodImageFile *iiFile) { if (!sOpenedFiles) sOpenedFiles = ilistNew(sizeof(ImodImageFile *), 4); if (sOpenedFiles && !ilistAppend(sOpenedFiles, &iiFile)) return 0; b3dError(stderr, "ERROR: iiOpen - Memory error adding new file to master list\n"); return 1; }
/* Initialize check list: if it does not exist, allocate it and place TIFF and MRC functions on the list */ static int initCheckList() { IIFileCheckFunction func; if (sCheckList) return 0; sCheckList = ilistNew(sizeof(IIFileCheckFunction), 6); if (!sCheckList) return 1; func = iiTIFFCheck; ilistAppend(sCheckList, &func); func = iiMRCCheck; ilistAppend(sCheckList, &func); func = iiLikeMRCCheck; ilistAppend(sCheckList, &func); func = iiHDFCheck; ilistAppend(sCheckList, &func); /* Turn off tiff unknown tag warnings: no effect if caller suppressed all warnings */ tiffFilterWarnings(); return 0; }
/*! * Inserts an item in [data] into [list] at the position given by [element]; * returns 1 if error */ int ilistInsert(Ilist *list, void *data, int element) { char *to; if (element < 0 || element > list->size) return 1; if (ilistAppend(list, data)) return 1; if (element == list->size - 1) return 0; ilistShift(list, element, 1); to = (char *)list->data + element * list->dsize; memcpy(to, data, list->dsize); return 0; }
// Add an item to the selection list void imodSelectionListAdd(ImodView *vi, Iindex newIndex) { int multiObject = 1; // Placekeeper for possible argument/preference Iindex *index; int i; // Clear list if a different object is given and multiobject not allowed if (ilistSize(vi->selectionList) && !multiObject) { index = (Iindex *)ilistFirst(vi->selectionList); if (index->object != newIndex.object) imodSelectionListClear(vi); } // create list if it does not exist if (!vi->selectionList) { vi->selectionList = ilistNew(sizeof(Iindex), 4); if (!vi->selectionList) return; // ERROR } // Look through list to see if contour is already there and update point for (i = 0; i < ilistSize(vi->selectionList); i++) { index = (Iindex *)ilistItem(vi->selectionList, i); if (index->object == newIndex.object && index->contour == newIndex.contour) { index->point = newIndex.point; imodTrace('S', "update %d %d %d", newIndex.object, newIndex.contour, newIndex.point); return; } } // Add index to list imodTrace('S', "adding %d %d %d", newIndex.object, newIndex.contour, newIndex.point); ilistAppend(vi->selectionList, &newIndex); dumpSelectionList(vi); }
/*! * Adds the given function to the end of the list of functions that iiOpen will * call to check a file. The format of the function is * ^ int iiFormatCheck(ImodImageFile *inFile) */ void iiAddCheckFunction(IIFileCheckFunction func) { if (initCheckList()) return; ilistAppend(sCheckList, &func); }