Project

General

Profile

Codes » History » Version 12

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