b636ea14fbe66e38121b6cb4df9eeb169b9ddfe7
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) 
22) #include "box.h"
23) #include "object.h"
24) #include "pixel.h"
25) #include "point.h"
26) 
27) Pixel::Pixel(const Object *pObjPixel):
28)   mpObjPixel(pObjPixel),
29)   mX(0),
30)   mY(0)
31) {
32) }
Stefan Schuermans make class members private

Stefan Schuermans authored 7 years ago

33) 
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

34) int Pixel::pixCoord(const Point &pix0, const Point &pixSz,
35)                     unsigned int width, unsigned int height)
36) {
37)   // get center of pixel
Stefan Schuermans implement simulator config...

Stefan Schuermans authored 7 years ago

38)   mpObjPixel->getBounds(mBounds);
39)   mBounds.getCenter(mCenter);
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

40) 
41)   // get coordinates of pixel
Stefan Schuermans implement simulator config...

Stefan Schuermans authored 7 years ago

42)   Point delta = mCenter - pix0;
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

43)   mX = (unsigned int)(delta.mX / pixSz.mX);
44)   mY = (unsigned int)(delta.mY / pixSz.mY);
45) 
46)   // check pixel coordinates
47)   if (mX >= width || mY >= height) {
Stefan Schuermans implement simulator config...

Stefan Schuermans authored 7 years ago

48)     std::cerr << "pixel at " << mCenter.mX << "," << mCenter.mY
Stefan Schuermans add config file generator

Stefan Schuermans authored 7 years ago

49)               << " is out of video frame (" << mX << "," << mY << ")"
50)               << std::endl;
51)     return -1;
52)   } else
53)     return 0;
54) }
55) 
56) void Pixel::writePixel(std::ostream & strm) const
57) {
58)   strm << " " << mX << "," << mY;
59) }
60) 
Stefan Schuermans keep aspect ratio of simula...

Stefan Schuermans authored 7 years ago

61) void Pixel::writeSimPixel(std::ostream & strm,
62)                           const Box & boundsVideoQuad) const
Stefan Schuermans implement simulator config...

Stefan Schuermans authored 7 years ago

63) {
64)   Point c, bl, tr;
Stefan Schuermans keep aspect ratio of simula...

Stefan Schuermans authored 7 years ago

65)   boundsVideoQuad.getRelative(mCenter, c);
66)   boundsVideoQuad.getRelative(mBounds.mBL, bl);
67)   boundsVideoQuad.getRelative(mBounds.mTR, tr);