362c1f4c3b5ce9e3fce11167a51fbe4cdb2174de
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp   1) /* Blinker
Stefan Schuermans update copyright header

Stefan Schuermans authored 5 years ago

src/common/CanvasInput.cpp   2)    Copyright 2011-2019 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

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

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  14) #include "InStreamFile.h"
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  15) #include "Position.h"
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  16) #include "PositionFile.h"
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  17) #include "Size.h"
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  18) #include "SizeFile.h"
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  19) #include "StreamMgr.h"
src/noarch/CanvasInput.cpp  20) #include "StreamRecv.h"
src/noarch/CanvasInput.cpp  21) 
src/noarch/CanvasInput.cpp  22) namespace Blinker {
src/noarch/CanvasInput.cpp  23) 
src/noarch/CanvasInput.cpp  24) /**
src/noarch/CanvasInput.cpp  25)  * @brief constructor
src/noarch/CanvasInput.cpp  26)  * @param[in] canvas owning canvas
Stefan Schuermans converted canvas module to...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  27)  * @param[in] name name of input
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  28)  * @param[in] dirBase base directory
src/noarch/CanvasInput.cpp  29)  */
Stefan Schuermans converted canvas module to...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  30) Canvas::Input::Input(Canvas &canvas, const std::string &name,
src/noarch/CanvasInput.cpp  31)                      const Directory &dirBase):
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  32)   m_canvas(canvas),
Stefan Schuermans converted canvas module to...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  33)   m_name(name),
Stefan Schuermans put all managers in one str...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  34)   m_fileInStream(dirBase.getFile("instream"), canvas.m_mgrs.m_streamMgr),
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  35)   m_fileSrcPos(dirBase.getFile("srcpos")),
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  36)   m_fileSize(dirBase.getFile("size")),
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  37)   m_fileDestPos(dirBase.getFile("destpos"))
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  38) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  39)   // set up
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  40)   getSrcPos();
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  41)   getSize();
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  42)   getDestPos();
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  43)   m_fileInStream.setStreamRecv(this);
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  44) }
src/noarch/CanvasInput.cpp  45) 
src/noarch/CanvasInput.cpp  46) /// virtual destructor
src/noarch/CanvasInput.cpp  47) Canvas::Input::~Input()
src/noarch/CanvasInput.cpp  48) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  49)   // clean up
src/noarch/CanvasInput.cpp  50)   m_fileInStream.setStreamRecv(NULL);
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  51) }
src/noarch/CanvasInput.cpp  52) 
src/noarch/CanvasInput.cpp  53) /// check for update of configuration
src/noarch/CanvasInput.cpp  54) void Canvas::Input::updateConfig()
src/noarch/CanvasInput.cpp  55) {
src/noarch/CanvasInput.cpp  56)   // input stream name file was modified -> re-get input stream
src/noarch/CanvasInput.cpp  57)   if (m_fileInStream.checkModified()) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  58)     m_fileInStream.update();
src/noarch/CanvasInput.cpp  59)     m_canvas.redraw(); // notify canvas to redraw
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  60)   }
src/noarch/CanvasInput.cpp  61) 
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  62)   // position/size files were modified -> re-get position/size
src/noarch/CanvasInput.cpp  63)   if (m_fileSrcPos.checkModified())
src/noarch/CanvasInput.cpp  64)     getSrcPos();
src/noarch/CanvasInput.cpp  65)   if (m_fileSize.checkModified())
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  66)     getSize();
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  67)   if (m_fileDestPos.checkModified())
src/noarch/CanvasInput.cpp  68)     getDestPos();
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  69) }
src/noarch/CanvasInput.cpp  70) 
src/noarch/CanvasInput.cpp  71) /**
src/noarch/CanvasInput.cpp  72)  * @brief set current frame
src/noarch/CanvasInput.cpp  73)  * @param[in] stream stream name
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  74)  * @param[in] pFrame current frame (NULL for none)
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  75)  */
src/noarch/CanvasInput.cpp  76) void Canvas::Input::setFrame(const std::string &stream, stBlinkenFrame *pFrame)
src/noarch/CanvasInput.cpp  77) {
src/noarch/CanvasInput.cpp  78)   // notify canvas to redraw
src/noarch/CanvasInput.cpp  79)   m_canvas.redraw();
src/noarch/CanvasInput.cpp  80) 
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  81)   (void)pFrame; // unused (frame fetched from stream when requested to draw)
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  82)   (void)stream; // unused
src/noarch/CanvasInput.cpp  83) }
src/noarch/CanvasInput.cpp  84) 
src/noarch/CanvasInput.cpp  85) /**
src/noarch/CanvasInput.cpp  86)  * @brief draw current frame to canvas
src/noarch/CanvasInput.cpp  87)  * @return if a frame was available and it was drawn
src/noarch/CanvasInput.cpp  88)  */
src/noarch/CanvasInput.cpp  89) bool Canvas::Input::draw()
src/noarch/CanvasInput.cpp  90) {
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  91)   stBlinkenFrame *pFrame;
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  92)   int destx, desty, srcx, srcy, width, height;
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  93) 
src/noarch/CanvasInput.cpp  94)   // no destination position or no canvas -> leave
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  95)   if (!m_fileDestPos.m_valid || !m_canvas.m_pCanvas)
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  96)     return false;
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  97)   destx = m_fileDestPos.m_obj.m_x;
src/noarch/CanvasInput.cpp  98)   desty = m_fileDestPos.m_obj.m_y;
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp  99) 
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 100)   // get current frame from stream (leave if no stream or no frame)
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 101)   pFrame = m_fileInStream.getCurFrame();
Stefan Schuermans merged frame processing wit...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 102)   if (!pFrame)
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 103)     return false;
src/noarch/CanvasInput.cpp 104) 
src/noarch/CanvasInput.cpp 105)   // no source position -> use top left
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 106)   if (m_fileSrcPos.m_valid) {
src/noarch/CanvasInput.cpp 107)     srcx = m_fileSrcPos.m_obj.m_x;
src/noarch/CanvasInput.cpp 108)     srcy = m_fileSrcPos.m_obj.m_y;
src/noarch/CanvasInput.cpp 109)   } else {
src/noarch/CanvasInput.cpp 110)     srcx = 0;
src/noarch/CanvasInput.cpp 111)     srcy = 0;
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 112)   }
src/noarch/CanvasInput.cpp 113) 
src/noarch/CanvasInput.cpp 114)   // no size -> use entire source frame
src/noarch/CanvasInput.cpp 115)   //            (BlinkenLib will clip this if too large)
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 116)   if (m_fileSize.m_valid) {
src/noarch/CanvasInput.cpp 117)     width = m_fileSize.m_obj.m_width;
src/noarch/CanvasInput.cpp 118)     height = m_fileSize.m_obj.m_height;
src/noarch/CanvasInput.cpp 119)   } else {
src/noarch/CanvasInput.cpp 120)     width = BlinkenFrameGetWidth(pFrame);
src/noarch/CanvasInput.cpp 121)     height = BlinkenFrameGetHeight(pFrame);
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 122)   }
src/noarch/CanvasInput.cpp 123) 
src/noarch/CanvasInput.cpp 124)   // draw rectangular area to canvas
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 125)   BlinkenFrameCopyRect(m_canvas.m_pCanvas, desty, destx,
src/noarch/CanvasInput.cpp 126)                        pFrame, srcy, srcx, height, width);
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 127) 
src/noarch/CanvasInput.cpp 128)   return true;
src/noarch/CanvasInput.cpp 129) }
src/noarch/CanvasInput.cpp 130) 
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 131) /// (re-)get position of area to copy from stream
src/noarch/CanvasInput.cpp 132) void Canvas::Input::getSrcPos()
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 133) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 134)   // read source position from file
src/noarch/CanvasInput.cpp 135)   m_fileSrcPos.update();
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 136) 
src/noarch/CanvasInput.cpp 137)   // notify canvas to redraw
src/noarch/CanvasInput.cpp 138)   m_canvas.redraw();
src/noarch/CanvasInput.cpp 139) }
src/noarch/CanvasInput.cpp 140) 
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 141) /// (re-)get size of area to copy from stream
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 142) void Canvas::Input::getSize()
src/noarch/CanvasInput.cpp 143) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 144)   // read size from file
src/noarch/CanvasInput.cpp 145)   m_fileSize.update();
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 146) 
src/noarch/CanvasInput.cpp 147)   // notify canvas to redraw
src/noarch/CanvasInput.cpp 148)   m_canvas.redraw();
src/noarch/CanvasInput.cpp 149) }
src/noarch/CanvasInput.cpp 150) 
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 151) /// (re-)get destination position on canvas
src/noarch/CanvasInput.cpp 152) void Canvas::Input::getDestPos()
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 153) {
Stefan Schuermans implemented specialized set...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 154)   // read destination position from file
src/noarch/CanvasInput.cpp 155)   m_fileDestPos.update();
Stefan Schuermans first version of canvas mod...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 156) 
Stefan Schuermans changed canvas to be able t...

Stefan Schuermans authored 12 years ago

src/noarch/CanvasInput.cpp 157)   // notify canvas to redraw
src/noarch/CanvasInput.cpp 158)   m_canvas.redraw();