Project

General

Profile

Codes » History » Version 19

Kentaro HARATAKE, 01/16/2025 02:02 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 19 Kentaro HARATAKE
``` python
8 5 Mitsuki EIKI
#!/usr/bin/env python
9
# -*- coding: utf-8 -*-
10 1 Mitsuki EIKI
from distutils.util import strtobool
11 16 Mitsuki EIKI
12 7 Mitsuki EIKI
class Config(object):
13 16 Mitsuki EIKI
    def __init__(self, pnd, prd, w, h, p, gamma, overlapWidth, side, isDual, monitorWidth): 
14 1 Mitsuki EIKI
        """!
15
        Constructor for Config class.
16 8 Mitsuki EIKI
17
        @param pnd: Projection distance.
18
        @param prd: Projector distance.
19
        @param w: Image width.
20
        @param h: Image height.
21
        @param p: Path to the image.
22
        @param gamma: Gamma value for adjustments.
23
        @param overlapWidth: Width of the overlap area.
24 1 Mitsuki EIKI
        @param side: Side of projection.
25 8 Mitsuki EIKI
        """
26 1 Mitsuki EIKI
        self.__projection_distance = pnd
27
        self.__projector_diatance = prd
28
        self.__img_width = w
29 8 Mitsuki EIKI
        self.__img_height = h
30
        self.__img_path = p
31
        self.__gamma = gamma
32
        self.__overlapWidth = overlapWidth
33
        self.__side = side
34
        self.__isDualMonitor = isDual
35
        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
        """!
95 1 Mitsuki EIKI
        Retrieve the side of projection.
96 8 Mitsuki EIKI
97
        @return: Side as a string.
98
        """
99
        return str(self.__side)
100 16 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
        __projection_distance = config["settings"]["projectionDistance"]
122 1 Mitsuki EIKI
        __projector_diatance = config["settings"]["projectorDistance"]
123
        __gamma = config["settings"]["gamma"]
124 8 Mitsuki EIKI
        __overlapWidth = config["settings"]["overlapWidth"]
125
        __side = config["settings"]["side"]
126
        __isDualMonitor = config["settings"]["isDualMonitor"]
127 1 Mitsuki EIKI
        __monitorWidth= config["settings"]["monitorWidth"]
128 16 Mitsuki EIKI
     
129
        return Config(__projection_distance, __projector_diatance, __img_width, __img_height, __img_path, __gamma, __overlapWidth, __side, __isDualMonitor, __monitorWidth)
130 19 Kentaro HARATAKE
```