void TransferFunctionEditor::loadState(Value& in) { transferFunction.loadState(in); setRange(transferFunction.GetMin(), transferFunction.GetMax()); transferFunctionAlphaScalingSlider.setValue(int(transferFunction.GetScale() * (transferFunctionAlphaScalingSlider.minimum() + transferFunctionAlphaScalingSlider.maximum()))); QVector<QPointF> points; for (int i = 0; i < transferFunction.GetAlphas().size(); i++) points.push_back(QPointF(transferFunction.GetAlphas()[i].x, transferFunction.GetAlphas()[i].y)); transferFunctionAlphaWidget.setPoints(points); if (in.HasMember("Colormap")) { ColorMap cmap; cmap.loadState(in["Colormap"]); int colorMapIndex; for(colorMapIndex = 0; colorMapIndex < colorMaps.size(); colorMapIndex++) if (colorMaps[colorMapIndex].getName() == cmap.getName()) break; if (colorMapIndex == colorMaps.size()) addColorMap(VColorMap(cmap)); colorMapComboBox.setCurrentIndex(colorMapIndex); } }
int setRasterLayerColormapName(Layer* pLayer, const char* pName) { RasterLayer* pRaster = dynamic_cast<RasterLayer*>(pLayer); if (pRaster == NULL) { setLastError(SIMPLE_BAD_PARAMS); return 1; } std::string name(pName); ColorMap map; if (!map.loadFromFile(name)) { // see if name is a colormap name const Filename* pSupportFiles = Service<ConfigurationSettings>()->getSettingSupportFilesPath(); if (pSupportFiles == NULL) { setLastError(SIMPLE_OTHER_FAILURE); return 1; } std::string mapDir = pSupportFiles->getFullPathAndName() + SLASH + "ColorTables" + SLASH; if (!map.loadFromFile(mapDir + name) && !map.loadFromFile(mapDir + name + ".clu") && !map.loadFromFile(mapDir + name + ".cgr")) { // scan all the default files and check for a valid name bool located = false; FactoryResource<FileFinder> pFinder; pFinder->findFile(mapDir, "*.c??"); while (pFinder->findNextFile()) { std::string filePath; pFinder->getFullPath(filePath); if (map.loadFromFile(filePath) && map.getName() == name) { located = true; break; } } if (!located) { setLastError(SIMPLE_NOT_FOUND); return 1; } } } pRaster->setColorMap(map); setLastError(SIMPLE_NO_ERROR); return 0; }