cb8a96f08c4fe625d87d0ae165fe7e4d06991f60
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) 
34) int Distri::pixCoord(const Point &pix0, const Point &pixSz,
35)                      unsigned int width, unsigned int height)
36) {
37)   bool err = false;
38)   if (mChains.size() > mChainCnt) {
39)     std::cerr << "too many chains (" << mChains.size() << "/"
40)               << mChainCnt << ") for distributor "
41)               << std::hex << mNo << std::endl;
42)     err = true;
43)   }
44)   std::vector<Chain>::iterator itC;
45)   unsigned int c;
46)   for (itC = mChains.begin(), c = 0; itC != mChains.end(); ++itC, ++c)
47)     if (itC->pixCoord(pix0, pixSz, width, height, mNo, c) != 0)
48)       err = true;
49)   return err ? -1 : 0;
50) }
51) 
52) void Distri::writeDistri(std::ostream &strm) const
53) {
54)   strm << "distributor " << mNo << " = "
55)        << mChainCnt << "," << mPixelCnt << std::endl;
56) }
57) 
58) void Distri::writeMapping(std::ostream &strm) const
59) {
60)   strm << "mapping " << mNo << " red = 0.0 1.0 1.0" << std::endl
61)        << "mapping " << mNo << " green = 0.0 1.0 1.0" << std::endl
62)        << "mapping " << mNo << " blue = 0.0 1.0 1.0" << std::endl;
63) }
64) 
65) void Distri::writePixels(std::ostream & strm) const
66) {
67)   std::vector<Chain>::const_iterator itC;
68)   unsigned int c;
69)   for (itC = mChains.begin(), c = 0; itC != mChains.end(); ++itC, ++c) {
70)     strm << "output " << mNo << "," << c << " =";
71)     itC->writePixels(strm);
72)     strm << std::endl;
73)   }
74) }
75)