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