646a131a8e8eeea149e820af709d70030819cc96
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

1) /*
Stefan Schuermans rename "FlexiPix" to "Ether...

Stefan Schuermans authored 7 years ago

2)  * EtherPix config file generator
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

3)  *
Stefan Schuermans update copyright year

Stefan Schuermans authored 7 years ago

4)  * Copyright 2010-2017 Stefan Schuermans <stefan schuermans info>
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

5)  *
6)  * This program is free software: you can redistribute it and/or modify
7)  * it under the terms of the GNU General Public License as published by
8)  * the Free Software Foundation, version 3 of the License.
9)  *
10)  *
11)  * This program is distributed in the hope that it will be useful,
12)  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14)  * GNU General Public License for more details.
15)  *
16)  * You should have received a copy of the GNU Lesser General Public License
17)  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18)  */
19) 
20) #include <iostream>
21) #include <vector>
22) 
23) #include "chain.h"
24) #include "distri.h"
25) #include "point.h"
26) 
27) Distri::Distri(unsigned int no, unsigned int chainCnt, unsigned int pixelCnt):
28)   mNo(no),
29)   mChainCnt(chainCnt),
30)   mPixelCnt(pixelCnt)
31) {
32) }
33) 
Stefan Schuermans make class members private

Stefan Schuermans authored 7 years ago

34) unsigned int Distri::getNo() const
35) {
36)   return mNo;
37) }
38) 
39) void Distri::addChain(Chain const &chain)
40) {
41)   mChains.push_back(chain);
42) }
43) 
44) Chain & Distri::accessLastChain()
45) {
46)   return mChains.back();
47) }
48) 
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

49) int Distri::pixCoord(const Point &pix0, const Point &pixSz,
50)                      unsigned int width, unsigned int height)
51) {
52)   bool err = false;
53)   if (mChains.size() > mChainCnt) {
54)     std::cerr << "too many chains (" << mChains.size() << "/"
Stefan Schuermans output hex numbers with 0x...

Stefan Schuermans authored 7 years ago

55)               << mChainCnt << ") for distributor 0x"
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

56)               << std::hex << mNo << std::endl;
57)     err = true;
58)   }
59)   std::vector<Chain>::iterator itC;
60)   unsigned int c;
61)   for (itC = mChains.begin(), c = 0; itC != mChains.end(); ++itC, ++c)
62)     if (itC->pixCoord(pix0, pixSz, width, height, mNo, c) != 0)
63)       err = true;
64)   return err ? -1 : 0;
65) }
66) 
67) void Distri::writeDistri(std::ostream &strm) const
68) {
69)   strm << "distributor " << mNo << " = "
70)        << mChainCnt << "," << mPixelCnt << std::endl;
71) }
72) 
73) void Distri::writeMapping(std::ostream &strm) const
74) {
75)   strm << "mapping " << mNo << " red = 0.0 1.0 1.0" << std::endl
76)        << "mapping " << mNo << " green = 0.0 1.0 1.0" << std::endl
77)        << "mapping " << mNo << " blue = 0.0 1.0 1.0" << std::endl;
78) }
79) 
80) void Distri::writePixels(std::ostream & strm) const
81) {
82)   std::vector<Chain>::const_iterator itC;
83)   unsigned int c;
84)   for (itC = mChains.begin(), c = 0; itC != mChains.end(); ++itC, ++c) {
85)     strm << "output " << mNo << "," << c << " =";
86)     itC->writePixels(strm);
87)     strm << std::endl;
88)   }
89) }
90) 
Stefan Schuermans implement simulator config...

Stefan Schuermans authored 7 years ago

91) void Distri::writeSimPixels(std::ostream & strm, const Box & boundsVideo) const
92) {
93)   std::vector<Chain>::const_iterator itC;
94)   unsigned int c;
95)   for (itC = mChains.begin(), c = 0; itC != mChains.end(); ++itC, ++c) {
96)     strm << "output " << mNo << "," << c << " =";
97)     itC->writeSimPixels(strm, boundsVideo);
98)     strm << std::endl;
99)   }
100) }
101)