Codes » History » Version 17
Mitsuki EIKI, 01/16/2025 02:01 PM
1 | 1 | Mitsuki EIKI | h1. Codes |
---|---|---|---|
2 | 2 | Mitsuki EIKI | |
3 | 3 | Man Mong CHAN | [[Wiki]] | [[About_Us]] | [[Project_Overview]] | [[UML_Diagram]] | [[Codes]] |
4 | 4 | Kentaro HARATAKE | |
5 | 6 | Mitsuki EIKI | |
6 | 10 | Mitsuki EIKI | |
7 | 16 | Mitsuki EIKI | ~~~ python |
8 | 17 | Mitsuki EIKI | """ |
9 | 5 | Mitsuki EIKI | #!/usr/bin/env python |
10 | # -*- coding: utf-8 -*- |
||
11 | 1 | Mitsuki EIKI | from distutils.util import strtobool |
12 | 16 | Mitsuki EIKI | |
13 | 7 | Mitsuki EIKI | class Config(object): |
14 | 16 | Mitsuki EIKI | def __init__(self, pnd, prd, w, h, p, gamma, overlapWidth, side, isDual, monitorWidth): |
15 | 1 | Mitsuki EIKI | """! |
16 | Constructor for Config class. |
||
17 | 8 | Mitsuki EIKI | |
18 | @param pnd: Projection distance. |
||
19 | @param prd: Projector distance. |
||
20 | @param w: Image width. |
||
21 | @param h: Image height. |
||
22 | @param p: Path to the image. |
||
23 | @param gamma: Gamma value for adjustments. |
||
24 | @param overlapWidth: Width of the overlap area. |
||
25 | 1 | Mitsuki EIKI | @param side: Side of projection. |
26 | 8 | Mitsuki EIKI | """ |
27 | 1 | Mitsuki EIKI | self.__projection_distance = pnd |
28 | self.__projector_diatance = prd |
||
29 | self.__img_width = w |
||
30 | 8 | Mitsuki EIKI | self.__img_height = h |
31 | self.__img_path = p |
||
32 | self.__gamma = gamma |
||
33 | self.__overlapWidth = overlapWidth |
||
34 | self.__side = side |
||
35 | self.__isDualMonitor = isDual |
||
36 | self.__monitorWidth = monitorWidth |
||
37 | |||
38 | 7 | Mitsuki EIKI | def getProjectionDistance(self): |
39 | 5 | Mitsuki EIKI | """! |
40 | Retrieve the projection distance. |
||
41 | 8 | Mitsuki EIKI | |
42 | @return: Projection distance as an integer. |
||
43 | 5 | Mitsuki EIKI | """ |
44 | return int(self.__projection_distance) |
||
45 | 1 | Mitsuki EIKI | |
46 | def getProjectorDistance(self): |
||
47 | """! |
||
48 | 5 | Mitsuki EIKI | Retrieve the projector distance. |
49 | 8 | Mitsuki EIKI | |
50 | @return: Projector distance as an integer. |
||
51 | 1 | Mitsuki EIKI | """ |
52 | return int(self.__projector_diatance) |
||
53 | |||
54 | 8 | Mitsuki EIKI | def getImgWidth(self): |
55 | """! |
||
56 | Retrieve the image width. |
||
57 | 1 | Mitsuki EIKI | |
58 | 8 | Mitsuki EIKI | @return: Image width as an integer. |
59 | """ |
||
60 | return int(self.__img_width) |
||
61 | |||
62 | def getImgHeight(self): |
||
63 | """! |
||
64 | Retrieve the image height. |
||
65 | |||
66 | @return: Image height as an integer. |
||
67 | """ |
||
68 | return int(self.__img_height) |
||
69 | |||
70 | def getImgPath(self): |
||
71 | """! |
||
72 | Retrieve the image path. |
||
73 | |||
74 | @return: Image path as a string. |
||
75 | """ |
||
76 | return str(self.__img_path) |
||
77 | |||
78 | def getGamma(self): |
||
79 | """! |
||
80 | Retrieve the gamma value. |
||
81 | |||
82 | @return: Gamma value as a float. |
||
83 | """ |
||
84 | return float(self.__gamma) |
||
85 | |||
86 | def getOverlapWidth(self): |
||
87 | """! |
||
88 | Retrieve the overlap width. |
||
89 | |||
90 | @return: Overlap width as an integer. |
||
91 | """ |
||
92 | return int(self.__overlapWidth) |
||
93 | |||
94 | def getSide(self): |
||
95 | """! |
||
96 | 1 | Mitsuki EIKI | Retrieve the side of projection. |
97 | 8 | Mitsuki EIKI | |
98 | @return: Side as a string. |
||
99 | """ |
||
100 | return str(self.__side) |
||
101 | 16 | Mitsuki EIKI | |
102 | 8 | Mitsuki EIKI | def getIsDualMonitor(self): |
103 | return bool(strtobool(self.__isDualMonitor)) |
||
104 | |||
105 | def getMonitorWidth(self): |
||
106 | return int(self.__monitorWidth) |
||
107 | |||
108 | 1 | Mitsuki EIKI | @staticmethod |
109 | def readConfigFile(): |
||
110 | """! |
||
111 | Reads the configuration from a config.ini file and returns a Config object. |
||
112 | 8 | Mitsuki EIKI | |
113 | @return: Config object with settings loaded from config.ini. |
||
114 | 1 | Mitsuki EIKI | """ |
115 | import configparser |
||
116 | 8 | Mitsuki EIKI | config = configparser.ConfigParser() |
117 | config.read('config.ini') |
||
118 | |||
119 | __img_path = config["settings"]["imagePath"] |
||
120 | __img_width = config["settings"]["imageWidth"] |
||
121 | __img_height = config["settings"]["imageHeight"] |
||
122 | __projection_distance = config["settings"]["projectionDistance"] |
||
123 | 1 | Mitsuki EIKI | __projector_diatance = config["settings"]["projectorDistance"] |
124 | __gamma = config["settings"]["gamma"] |
||
125 | 8 | Mitsuki EIKI | __overlapWidth = config["settings"]["overlapWidth"] |
126 | __side = config["settings"]["side"] |
||
127 | __isDualMonitor = config["settings"]["isDualMonitor"] |
||
128 | 1 | Mitsuki EIKI | __monitorWidth= config["settings"]["monitorWidth"] |
129 | 16 | Mitsuki EIKI | |
130 | return Config(__projection_distance, __projector_diatance, __img_width, __img_height, __img_path, __gamma, __overlapWidth, __side, __isDualMonitor, __monitorWidth) |
||
131 | 17 | Mitsuki EIKI | """ |
132 | 15 | Mitsuki EIKI | ~~~ |