changeset 256:e35740ed81f3

- Support for output as a set of PNG files.
author tomwalters
date Sun, 14 Nov 2010 05:56:50 +0000
parents b953e295b49e
children c02260afd0d8
files src/Configurations/SAI_movie.aimcconfig src/Modules/Output/Graphics/Devices/GraphicsOutputDeviceCairo.cc src/Modules/Output/Graphics/Devices/GraphicsOutputDeviceCairo.h src/Modules/Output/Graphics/GraphicsView.cc src/Modules/Output/Graphics/GraphicsViewTime.cc src/Support/SignalBank.h
diffstat 6 files changed, 44 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/Configurations/SAI_movie.aimcconfig	Sun Nov 07 07:38:20 2010 +0000
+++ b/src/Configurations/SAI_movie.aimcconfig	Sun Nov 14 05:56:50 2010 +0000
@@ -27,5 +27,6 @@
 graph.y.max=0.5
 graph.freq.label=Cochlear Channel
 graph.x.label=Time Interval
-graph.type=line
+graph.type=colormap
+output.images=true
 ENDPARAMS
--- a/src/Modules/Output/Graphics/Devices/GraphicsOutputDeviceCairo.cc	Sun Nov 07 07:38:20 2010 +0000
+++ b/src/Modules/Output/Graphics/Devices/GraphicsOutputDeviceCairo.cc	Sun Nov 14 05:56:50 2010 +0000
@@ -45,12 +45,37 @@
   m_iFileNumber = 0;
   m_iVertexType = VertexTypeNone;
   m_bUseMemoryBuffer=false;
-  parameters_->DefaultString("output.img.format", ".png");
+  parameters_->DefaultString("output.img.format", "png");
+}
+
+void GraphicsOutputDeviceCairo::Reset(Parameters* global_parameters) {
+  Initialize(global_parameters);
+}
+
+bool GraphicsOutputDeviceCairo::Initialize(Parameters *global_parameters) {
+  global_parameters_ = global_parameters;
+#ifdef _WINDOWS
+  string pathsep("\\");
+#else
+  string pathsep("/");
+#endif
+  directory_ = global_parameters->GetString("output_filename_base") + pathsep;
+    //! \todo Make build system check for mkdtemp() to use it when available. See TODO.txt.
+#ifdef _WINDOWS
+  if (_mkdir(directory_.c_str()) < 0) {
+    LOG_ERROR(_T("Couldn't create directory for image output."));
+    return false;
+  }
+#else
+  mkdir(directory_.c_str(), S_IRWXU);
+#endif
+  InitialzeInternal();
+  return true;
 }
 
 bool GraphicsOutputDeviceCairo::Initialize(string directory) {
   directory_ = directory;
-  InititalzeInternal();
+  InitialzeInternal();
 
   /* Try to open an image to see if everything is allright. We want to avoid
    * errors in the main Process()ing loop. */
@@ -71,7 +96,7 @@
     return(true);
 }*/
 
-void GraphicsOutputDeviceCairo::InititalzeInternal() {
+void GraphicsOutputDeviceCairo::InitialzeInternal() {
    AIM_ASSERT(parameters_);
 
   parameters_->DefaultString("output.img.color.background", "black");
@@ -235,12 +260,11 @@
                        1 - m_aPrevY[2], m_aPrevX[2] - m_aPrevX[0],
                        y - m_aPrevY[2]);
       cairo_fill (m_cCr);
-      
+
       /*cairo_move_to(m_cCr, , );
       cairo_line_to(m_cCr, , 1 - m_aPrevY[1]);
       cairo_line_to(m_cCr, x, y);
       cairo_line_to(m_cCr, m_aPrevX[2], 1 - m_aPrevY[2]);*/
- 
 
       // Last vertices of this quad are the first of the next
       m_aPrevX[0] = m_aPrevX[2];
--- a/src/Modules/Output/Graphics/Devices/GraphicsOutputDeviceCairo.h	Sun Nov 07 07:38:20 2010 +0000
+++ b/src/Modules/Output/Graphics/Devices/GraphicsOutputDeviceCairo.h	Sun Nov 14 05:56:50 2010 +0000
@@ -64,6 +64,8 @@
    *  Initialize() failed, you shouldn't try the other functions either.
    */
   bool Initialize(string directory);
+virtual bool Initialize(Parameters *global_parameters);
+  
   void gGrab();
   void gBeginLineStrip();
   void gBeginQuadStrip();
@@ -75,11 +77,12 @@
   void gRelease();
   unsigned char* GetBuffer();
   int GetPixelFormat();
+  virtual void Reset(Parameters* global_parameters);
  protected:
   /*! \brief Internal initialisation
    *
    */
-  void InititalzeInternal();
+  void InitialzeInternal();
 
   /*! \brief Open the file with given index for output
    *  \param index File number to open
--- a/src/Modules/Output/Graphics/GraphicsView.cc	Sun Nov 07 07:38:20 2010 +0000
+++ b/src/Modules/Output/Graphics/GraphicsView.cc	Sun Nov 14 05:56:50 2010 +0000
@@ -30,8 +30,12 @@
   module_identifier_ = "graphics";
   module_type_ = "output";
   module_version_ = "$Id: $";
-  
-  m_pDev = new GraphicsOutputDeviceMovie(parameters);
+
+  if (parameters_->DefaultBool("output.images", false)) {
+    m_pDev = new GraphicsOutputDeviceCairo(parameters_);
+  } else {
+    m_pDev = new GraphicsOutputDeviceMovie(parameters_);
+  }
   m_bPlotLabels = false;
   m_pAxisX = new GraphAxisSpec();
   AIM_ASSERT(m_pAxisX);
--- a/src/Modules/Output/Graphics/GraphicsViewTime.cc	Sun Nov 07 07:38:20 2010 +0000
+++ b/src/Modules/Output/Graphics/GraphicsViewTime.cc	Sun Nov 14 05:56:50 2010 +0000
@@ -84,7 +84,7 @@
            m_pAxisX->m_fMin,
            m_pAxisX->m_fMax,
            m_pAxisX->m_pScale->getName());
- 
+
   m_pDev->gText2f(m_fMarginLeft, 0.0025f, sTxt, false);
 
   // Frame time
--- a/src/Support/SignalBank.h	Sun Nov 07 07:38:20 2010 +0000
+++ b/src/Support/SignalBank.h	Sun Nov 14 05:56:50 2010 +0000
@@ -64,7 +64,7 @@
   inline const vector<float> &get_signal(int channel) const {
     return signals_[channel];
   };
-  
+
   // Return a reference to the signal vector. The reference is not
   // const, so the vector is directly modifiable. In order to maintain
   // consistency of the data within the filterbank, the size of this
@@ -74,7 +74,7 @@
   inline vector<float> &get_mutable_signal(int channel) {
     return signals_[channel];
   };
-  
+
   inline void set_signal(int channel, vector<float> input) {
     signals_[channel] = input;
   }