Project

General

Profile

Codes » History » Version 15

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