-int HistogramMain::load_defaults()
-{
- char directory[BCTEXTLEN], string[BCTEXTLEN];
-// set the default directory
- sprintf(directory, "%shistogram.rc", BCASTDIR);
-
-// load the defaults
- defaults = new BC_Hash(directory);
- defaults->load();
-
- for(int j = 0; j < HISTOGRAM_MODES; j++)
- {
- while(config.points[j].last) delete config.points[j].last;
-
- sprintf(string, "TOTAL_POINTS_%d", j);
- int total_points = defaults->get(string, 0);
-
- for(int i = 0; i < total_points; i++)
- {
- HistogramPoint *point = new HistogramPoint;
- sprintf(string, "INPUT_X_%d_%d", j, i);
- point->x = defaults->get(string, point->x);
- sprintf(string, "INPUT_Y_%d_%d", j, i);
- point->y = defaults->get(string, point->y);
- sprintf(string, "GRADIENT_%d_%d", j, i);
- point->gradient = defaults->get(string, point->gradient);
- sprintf(string, "XOFFSET_LEFT_%d_%d", j, i);
- point->xoffset_left = defaults->get(string, point->xoffset_left);
- sprintf(string, "XOFFSET_RIGHT_%d_%d", j, i);
- point->xoffset_right = defaults->get(string, point->xoffset_right);
- config.points[j].append(point);
- }
- }
-
-
- for(int i = 0; i < HISTOGRAM_MODES; i++)
- {
- sprintf(string, "OUTPUT_MIN_%d", i);
- config.output_min[i] = defaults->get(string, config.output_min[i]);
- sprintf(string, "OUTPUT_MAX_%d", i);
- config.output_max[i] = defaults->get(string, config.output_max[i]);
- }
-
- config.automatic = defaults->get("AUTOMATIC", config.automatic);
- mode = defaults->get("MODE", mode);
- CLAMP(mode, 0, HISTOGRAM_MODES - 1);
- config.threshold = defaults->get("THRESHOLD", config.threshold);
- config.split = defaults->get("SPLIT", config.split);
- config.smoothMode = defaults->get("INTERPOLATION", config.smoothMode);
- config.boundaries();
- return 0;
-}
-
-
-int HistogramMain::save_defaults()
-{
- char string[BCTEXTLEN];
-
-
-
- for(int j = 0; j < HISTOGRAM_MODES; j++)
- {
- int total_points = config.points[j].total();
- sprintf(string, "TOTAL_POINTS_%d", j);
- defaults->update(string, total_points);
- HistogramPoint *current = config.points[j].first;
- int number = 0;
- while(current)
- {
- sprintf(string, "INPUT_X_%d_%d", j, number);
- defaults->update(string, current->x);
- sprintf(string, "INPUT_Y_%d_%d", j, number);
- defaults->update(string, current->y);
- sprintf(string, "GRADIENT_%d_%d", j, number);
- defaults->update(string, current->gradient);
- sprintf(string, "XOFFSET_LEFT_%d_%d", j, number);
- defaults->update(string, current->xoffset_left);
- sprintf(string, "XOFFSET_RIGHT_%d_%d", j, number);
- defaults->update(string, current->xoffset_right);
- current = NEXT;
- number++;
- }
- }
-
-
- for(int i = 0; i < HISTOGRAM_MODES; i++)
- {
- sprintf(string, "OUTPUT_MIN_%d", i);
- defaults->update(string, config.output_min[i]);
- sprintf(string, "OUTPUT_MAX_%d", i);
- defaults->update(string, config.output_max[i]);
- }
-
- defaults->update("AUTOMATIC", config.automatic);
- defaults->update("MODE", mode);
- defaults->update("THRESHOLD", config.threshold);
- defaults->update("SPLIT", config.split);
- defaults->update("INTERPOLATION", config.smoothMode);
- defaults->save();
- return 0;
-}
-
-
-