f670ca05dd608c9d5b0300ca1dc493f6ffd8afa1
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp   1) /* Blinker
Stefan Schuermans update copyright years

Stefan Schuermans authored 10 years ago

src/noarch/Canvas.cpp   2)    Copyright 2011-2014 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp   3)    Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
src/noarch/Canvas.cpp   4)    a blinkenarea.org project */
src/noarch/Canvas.cpp   5) 
src/noarch/Canvas.cpp   6) #include <list>
src/noarch/Canvas.cpp   7) #include <string>
src/noarch/Canvas.cpp   8) 
src/noarch/Canvas.cpp   9) #include <BlinkenLib/BlinkenFrame.h>
src/noarch/Canvas.cpp  10) 
src/noarch/Canvas.cpp  11) #include "Canvas.h"
src/noarch/Canvas.cpp  12) #include "CanvasInput.h"
src/noarch/Canvas.cpp  13) #include "Directory.h"
src/noarch/Canvas.cpp  14) #include "File.h"
src/noarch/Canvas.cpp  15) #include "Format.h"
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  16) #include "FormatFile.h"
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  17) #include "Mgrs.h"
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  18) #include "Module.h"
Stefan Schuermans converted canvas module to...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  19) #include "ListTracker.h"
src/noarch/Canvas.cpp  20) #include "ListTracker_impl.h"
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  21) #include "OutStreamFile.h"
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  22) #include "StreamRecv.h"
src/noarch/Canvas.cpp  23) 
src/noarch/Canvas.cpp  24) namespace Blinker {
src/noarch/Canvas.cpp  25) 
src/noarch/Canvas.cpp  26) /**
src/noarch/Canvas.cpp  27)  * @brief constructor
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  28)  * @param[in] name module name
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  29)  * @param[in] mgrs managers
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  30)  * @param[in] dirBase base directory
src/noarch/Canvas.cpp  31)  */
Stefan Schuermans make modules know their name

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  32) Canvas::Canvas(const std::string &name, Mgrs &mgrs, const Directory &dirBase):
src/noarch/Canvas.cpp  33)   Module(name, mgrs, dirBase),
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  34)   m_fileFormat(dirBase.getFile("format")),
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  35)   m_fileOutStream(dirBase.getFile("outstream"), mgrs.m_streamMgr),
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  36)   m_pCanvas(NULL),
Stefan Schuermans converted canvas module to...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  37)   m_canvasHasFrame(false),
src/noarch/Canvas.cpp  38)   m_inListTracker(*this, dirBase.getSubdir("inputs"))
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  39) {
src/noarch/Canvas.cpp  40)   // set up
src/noarch/Canvas.cpp  41)   createCanvas();
Stefan Schuermans converted canvas module to...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  42)   m_inListTracker.init();
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  43) }
src/noarch/Canvas.cpp  44) 
src/noarch/Canvas.cpp  45) /// virtual destructor
src/noarch/Canvas.cpp  46) Canvas::~Canvas()
src/noarch/Canvas.cpp  47) {
src/noarch/Canvas.cpp  48)   // clean up
Stefan Schuermans converted canvas module to...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  49)   m_inListTracker.clear();
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  50)   destroyCanvas();
src/noarch/Canvas.cpp  51) }
src/noarch/Canvas.cpp  52) 
src/noarch/Canvas.cpp  53) /// check for update of configuration
src/noarch/Canvas.cpp  54) void Canvas::updateConfig()
src/noarch/Canvas.cpp  55) {
src/noarch/Canvas.cpp  56)   // format file was modified -> re-create canvas
src/noarch/Canvas.cpp  57)   if (m_fileFormat.checkModified()) {
src/noarch/Canvas.cpp  58)     createCanvas();
src/noarch/Canvas.cpp  59)   }
src/noarch/Canvas.cpp  60) 
Stefan Schuermans converted canvas module to...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  61)   // input list update
src/noarch/Canvas.cpp  62)   m_inListTracker.updateConfig();
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  63) 
src/noarch/Canvas.cpp  64)   // output stream name file was modified -> re-get output stream
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  65)   if (m_fileOutStream.checkModified())
src/noarch/Canvas.cpp  66)     m_fileOutStream.update();
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  67) }
src/noarch/Canvas.cpp  68) 
src/noarch/Canvas.cpp  69) /// (re-)create canvas
src/noarch/Canvas.cpp  70) void Canvas::createCanvas()
src/noarch/Canvas.cpp  71) {
src/noarch/Canvas.cpp  72)   // get rid of old canvas
src/noarch/Canvas.cpp  73)   destroyCanvas();
src/noarch/Canvas.cpp  74) 
src/noarch/Canvas.cpp  75)   // read format from format file
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  76)   m_fileFormat.update();
src/noarch/Canvas.cpp  77)   if (!m_fileFormat.m_valid)
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  78)     return;
src/noarch/Canvas.cpp  79) 
src/noarch/Canvas.cpp  80)   // create frame
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  81)   m_pCanvas = BlinkenFrameNew(m_fileFormat.m_obj.m_height,
src/noarch/Canvas.cpp  82)                               m_fileFormat.m_obj.m_width,
src/noarch/Canvas.cpp  83)                               m_fileFormat.m_obj.m_channels,
src/noarch/Canvas.cpp  84)                               m_fileFormat.m_obj.m_maxval, 1);
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  85)   m_canvasHasFrame = false;
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  86) }
src/noarch/Canvas.cpp  87) 
src/noarch/Canvas.cpp  88) /// tear down canvas
src/noarch/Canvas.cpp  89) void Canvas::destroyCanvas()
src/noarch/Canvas.cpp  90) {
src/noarch/Canvas.cpp  91)   if (m_pCanvas) {
src/noarch/Canvas.cpp  92)     BlinkenFrameFree(m_pCanvas);
src/noarch/Canvas.cpp  93)     m_pCanvas = NULL;
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  94)     m_canvasHasFrame = false;
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp  95)   }
src/noarch/Canvas.cpp  96) }
src/noarch/Canvas.cpp  97) 
src/noarch/Canvas.cpp  98) /// notfication to redraw (called by inputs)
src/noarch/Canvas.cpp  99) void Canvas::redraw()
src/noarch/Canvas.cpp 100) {
src/noarch/Canvas.cpp 101)   // do nothing if there is no canvas
src/noarch/Canvas.cpp 102)   if (!m_pCanvas)
src/noarch/Canvas.cpp 103)     return;
src/noarch/Canvas.cpp 104) 
src/noarch/Canvas.cpp 105)   // black background
src/noarch/Canvas.cpp 106)   BlinkenFrameClear(m_pCanvas);
src/noarch/Canvas.cpp 107)   m_canvasHasFrame = false; // no frame on canvas yet
src/noarch/Canvas.cpp 108) 
src/noarch/Canvas.cpp 109)   // tell all inputs to draw on canvas
Stefan Schuermans converted canvas module to...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp 110)   InListTracker::ListIt itIn;
src/noarch/Canvas.cpp 111)   for (itIn = m_inListTracker.m_list.begin();
src/noarch/Canvas.cpp 112)        itIn != m_inListTracker.m_list.end(); ++itIn)
src/noarch/Canvas.cpp 113)     if (itIn->m_pObj->draw())
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp 114)       m_canvasHasFrame = true; // drawing successful -> there is a frame now
src/noarch/Canvas.cpp 115) 
src/noarch/Canvas.cpp 116)   // send current frame to stream
src/noarch/Canvas.cpp 117)   sendFrame();
src/noarch/Canvas.cpp 118) }
src/noarch/Canvas.cpp 119) 
src/noarch/Canvas.cpp 120) /// send current frame to output stream
src/noarch/Canvas.cpp 121) void Canvas::sendFrame()
src/noarch/Canvas.cpp 122) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/Canvas.cpp 123)   // frame available -> send it
src/noarch/Canvas.cpp 124)   if (m_canvasHasFrame)
src/noarch/Canvas.cpp 125)     m_fileOutStream.setFrame(m_pCanvas);
src/noarch/Canvas.cpp 126)   // no frame available -> send this information
src/noarch/Canvas.cpp 127)   else
src/noarch/Canvas.cpp 128)     m_fileOutStream.setFrame(NULL);