Commit 4933833e801e75915dc370e1e34ced57311a80cc

Authored by Benjamin Renard
2 parents a5eafe24 95e26447

Merge branch 'FER_19836' into amdadev

CMakeLists.txt
... ... @@ -145,6 +145,7 @@ add_subdirectory(src/ParamOutputImpl/Statistic)
145 145 add_subdirectory(src/TimeTableCatalog)
146 146 add_subdirectory(src/TTOperations)
147 147 add_subdirectory(src/TTConversion)
  148 +add_subdirectory(src/colorMapGen)
148 149 add_subdirectory(src/ParamGetImpl/DDServerInterface)
149 150 add_subdirectory(src/ParamGetImpl/LocalFileInterface)
150 151 add_subdirectory(src/ParamGetImpl/ConstantInterface)
... ...
src/ParamOutputImpl/Plot/PlotOutput.cc
... ... @@ -12,6 +12,7 @@
12 12 #include "LayoutAuto.hh"
13 13 #include "LayoutVertical.hh"
14 14 #include "TimePlotNode.hh"
  15 +#include "ShadesTools.hh"
15 16 #include "Time/TimePlot.hh"
16 17  
17 18 #include <boost/range/adaptor/reversed.hpp>
... ... @@ -68,6 +69,81 @@ void PlotOutput::init()
68 69 }
69 70 }
70 71  
  72 +void PlotOutput::palToSvg(const std::string& palPath)
  73 +{
  74 + // Initialize the PLplot library
  75 + plsdev("svg");
  76 + std::string svgPath = palPath;
  77 + svgPath.replace(svgPath.find(".pal"),4,".svg");
  78 + plsfnam(svgPath.c_str());
  79 +
  80 + // Set dimensions
  81 + plspage(0,0,300,45,0,0);
  82 +
  83 + plinit();
  84 +
  85 + // Set up the color map
  86 + plspal1(palPath.c_str(),1);
  87 + pladv(0);
  88 + // Set up the viewport
  89 + plvpor(0,1,0,1);
  90 + plwind(0.0, 1.0, 0.0, 1.0); // xmin, xmax, ymin, ymax
  91 +
  92 + // Create the color bar
  93 + PLFLT colorBarWidth = 1;
  94 + PLFLT colorBarHeight = 1;
  95 +
  96 + PLINT label_opts[1];
  97 + label_opts[0] = PL_COLORBAR_LABEL_LEFT;
  98 + const char *labels[0];
  99 + const char *axis_opts[1]={""};
  100 +
  101 + PLFLT axis_ticks[1] = {0};
  102 + PLINT axis_subticks[1] = {0};
  103 +
  104 + // set nb og colors
  105 + const int nbCol = 20;
  106 +
  107 + PLINT num_values[1] = {nbCol + 1};
  108 +
  109 + PLFLT *shedge = new PLFLT[nbCol + 1];
  110 + Range r(0,1);
  111 +
  112 + ShadesTools::computeEdgesLevels(r, nbCol + 1, shedge);
  113 +
  114 + PLFLT *values[1];
  115 + values[0] = shedge;
  116 +
  117 + plcolorbar(
  118 + &colorBarWidth,
  119 + &colorBarHeight,
  120 + PL_COLORBAR_GRADIENT, // PL_COLORBAR_SHADE,
  121 + PL_POSITION_BOTTOM | PL_POSITION_INSIDE,
  122 + 0.0, // COLORBAR_X_OFFSET,
  123 + 0.0,
  124 + 1,
  125 + 1,
  126 + 0, /*bg_color*/
  127 + 1,
  128 + 1,
  129 + 0.0,
  130 + 0.0,
  131 + 0,
  132 + 0,
  133 + 0,
  134 + label_opts,
  135 + labels,
  136 + 1,
  137 + axis_opts,
  138 + axis_ticks,
  139 + axis_subticks,
  140 + num_values,
  141 + (const PLFLT *const *)values);
  142 +
  143 + // Clean up
  144 + plend();
  145 +}
  146 +
71 147 /**
72 148 * Gets parameter value from server and stores them into dedicated
73 149 * structure.
... ...
src/ParamOutputImpl/Plot/PlotOutput.hh
... ... @@ -38,6 +38,8 @@ public:
38 38 */
39 39 virtual void apply();
40 40  
  41 + void palToSvg(const std::string& palPath);
  42 +
41 43 /**
42 44 * @brief Adds a plot to the plot list.
43 45 */
... ...
src/colorMapGen/CMakeLists.txt 0 โ†’ 100644
... ... @@ -0,0 +1,51 @@
  1 +
  2 +PROJECT(colorMapGen)
  3 +
  4 +include_directories(
  5 + ${CMAKE_HOME_DIRECTORY}/src/TimeUtil/
  6 + ${CMAKE_HOME_DIRECTORY}/src/helpers/
  7 + ${CMAKE_HOME_DIRECTORY}/src/Info/
  8 + ${CMAKE_HOME_DIRECTORY}/src/Common/
  9 + ${CMAKE_HOME_DIRECTORY}/src/ParamOutputImpl/Plot/
  10 + ${CMAKE_HOME_DIRECTORY}/src/ParamOutputImpl/Plot/Scatter/
  11 + ${CMAKE_HOME_DIRECTORY}/src/Parameters/
  12 + ${CMAKE_HOME_DIRECTORY}/src/PostProcessing/
  13 + ${CMAKE_HOME_DIRECTORY}/src/XMLConfigurator/
  14 + ${CMAKE_HOME_DIRECTORY}/src/XMLParameterConfigurator/
  15 + ${CMAKE_HOME_DIRECTORY}/src/Plugins/
  16 + ${CMAKE_HOME_DIRECTORY}/src/TimeTableCatalog/
  17 + ${CMAKE_HOME_DIRECTORY}/src/SpiceKernel/
  18 + ${DDCLIENTINCLUDE_DIR}
  19 + ${LOG4CXX_INCLUDE_DIR}
  20 + ${LIBXML2_INCLUDE_DIR}
  21 + ${Boost_INCLUDE_DIR}
  22 +)
  23 +
  24 +#Configuration de la librairie
  25 +file(
  26 + GLOB_RECURSE
  27 + source_files
  28 + ./*
  29 +)
  30 +
  31 +ADD_EXECUTABLE( colorMapGen ${source_files} )
  32 +
  33 +
  34 +target_link_libraries(
  35 + colorMapGen
  36 + TimeUtil
  37 + AMDA_COMMON
  38 + ${CMAKE_THREAD_LIBS_INIT}
  39 + Parameters
  40 + ${LOG4CXX_LIBRARIES}
  41 + ${LIBXML2_LIBRARIES}
  42 + ${Boost_LIBRARIES}
  43 + Plugin
  44 + XMLParameterConfigurator
  45 + ParamOutputImpl
  46 + TimeTableCatalog
  47 + Plot
  48 + Info
  49 + SpiceKernel
  50 + ${DDCLIENTLIBRARY}
  51 +)
... ...
src/colorMapGen/Main.cc 0 โ†’ 100644
... ... @@ -0,0 +1,80 @@
  1 +/**
  2 + * Main.cc
  3 + * Created on: 18 mar. 2016
  4 + * Author: AKKA IS
  5 + */
  6 +
  7 +#include <iostream>
  8 +
  9 +#include <boost/program_options.hpp>
  10 +
  11 +#include "AMDA-Kernel_Config.hh"
  12 +#include "ParameterManager.hh"
  13 +#include "PlotOutput.hh"
  14 +#include <Application.hh>
  15 +
  16 +// Parameters module include
  17 +#include "Process.hh"
  18 +#include "ServicesServer.hh"
  19 +#include "TimeUtil.hh"
  20 +
  21 +using namespace std;
  22 +namespace po = boost::program_options;
  23 +using namespace log4cxx;
  24 +using namespace log4cxx::helpers;
  25 +using namespace AMDA::Parameters;
  26 +
  27 +#define MAX_YEAR 2040
  28 +
  29 +/**
  30 + * Main function
  31 + */
  32 +int main(int argc, char *argv[]) {
  33 + int result = AMDA_EXIT_OK;
  34 +
  35 + /// Parse command line parameters
  36 + po::options_description desc("Allowed options");
  37 +
  38 + desc.add_options()
  39 + ("help,h", "Produce help message")
  40 + ("version,v", "Program version")
  41 + ("palette,p", po::value< vector<string> >(), "Color palette(s) file(s)")
  42 + ;
  43 +
  44 + po::positional_options_description p;
  45 + p.add("palette", -1);
  46 +
  47 + po::variables_map vm;
  48 + po::store(po::command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
  49 + po::notify(vm);
  50 +
  51 + if (vm.count("help")) {
  52 + cout << desc << "\n";
  53 + return result;
  54 + }
  55 + if (vm.count("version")) {
  56 + cout << "Version: " << AMDA_Kernel_VERSION << "\n";
  57 + return result;
  58 + }
  59 +
  60 + if (!vm.count("palette")) {
  61 + return result;
  62 + }
  63 +
  64 + AMDA::Common::Application lMain;
  65 +
  66 + return lMain.main(argc,argv,[&](int , char **, AMDA::helpers::Properties& /*lProperties*/) -> int {
  67 +
  68 + ParameterManager parameterManager;
  69 + plot::PlotOutput plotOutput(parameterManager);
  70 + std::vector<std::string> paletteList = vm["palette"].as< std::vector<string> >();
  71 +
  72 + for(auto palette:paletteList){
  73 + plotOutput.palToSvg(palette);
  74 + }
  75 +
  76 + return result;
  77 + });
  78 +
  79 +}
  80 +
... ...