2 * Copyright (c) 1997 Silicon Graphics, Inc. All Rights Reserved.
3 * Copyright (c) 2009 Aconex. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 #include "defaultobj.h"
16 #include "colorlist.h"
22 DefaultObj
*DefaultObj::theDefaultObj
;
24 DefaultObj::DefaultObj()
37 _baseColor
[0] = _baseColor
[1] = _baseColor
[2] = 0.15;
38 _labelColor
[0] = _labelColor
[1] = _labelColor
[2] = 1.0;
39 _pipeLength
= _barHeight
;
46 theDefaultObj
= new DefaultObj
;
47 theDefaultObj
->getResources();
49 return *theDefaultObj
;
53 DefaultObj::changeDefObj()
56 theDefaultObj
= new DefaultObj
;
57 theDefaultObj
->getResources();
59 return *theDefaultObj
;
62 DefaultObj::DefaultObj(const DefaultObj
&rhs
)
63 : _baseBorderX(rhs
._baseBorderX
),
64 _baseBorderZ(rhs
._baseBorderZ
),
65 _baseHeight(rhs
._baseHeight
),
66 _barSpaceX(rhs
._barSpaceX
),
67 _barSpaceZ(rhs
._barSpaceZ
),
68 _barSpaceLabel(rhs
._barSpaceLabel
),
69 _barLength(rhs
._barLength
),
70 _barHeight(rhs
._barHeight
),
71 _labelMargin(rhs
._labelMargin
),
72 _gridMinWidth(rhs
._gridMinWidth
),
73 _gridMinDepth(rhs
._gridMinDepth
),
74 _pipeLength(rhs
._pipeLength
)
78 for (i
= 0; i
< 3; i
++) {
79 _baseColor
[i
] = rhs
._baseColor
[i
];
80 _labelColor
[i
] = rhs
._labelColor
[i
];
85 DefaultObj::operator=(const DefaultObj
&rhs
)
90 _baseBorderX
= rhs
._baseBorderX
;
91 _baseBorderZ
= rhs
._baseBorderZ
;
92 _baseHeight
= rhs
._baseHeight
;
93 _barSpaceX
= rhs
._barSpaceX
;
94 _barSpaceZ
= rhs
._barSpaceZ
;
95 _barSpaceLabel
= rhs
._barSpaceLabel
;
96 _barLength
= rhs
._barLength
;
97 _barHeight
= rhs
._barHeight
;
98 _labelMargin
= rhs
._labelMargin
;
99 _gridMinWidth
= rhs
._gridMinWidth
;
100 _gridMinDepth
= rhs
._gridMinDepth
;
102 for (i
= 0; i
< 3; i
++) {
103 _baseColor
[i
] = rhs
._baseColor
[i
];
104 _labelColor
[i
] = rhs
._labelColor
[i
];
111 operator<<(QTextStream
&os
, const DefaultObj
&rhs
)
113 os
<< "baseBorderX=" << rhs
._baseBorderX
;
114 os
<< ", baseBorderZ=" << rhs
._baseBorderZ
;
115 os
<< ", baseHeight=" << rhs
._baseHeight
;
116 os
<< ", baseColor=" << rhs
._baseColor
[0] << ',' << rhs
._baseColor
[1]
117 << ',' << rhs
._baseColor
[2] << endl
;
118 os
<< ", barSpaceX=" << rhs
._barSpaceX
;
119 os
<< ", barSpaceZ=" << rhs
._barSpaceZ
;
120 os
<< ", barSpaceLabel=" << rhs
._barSpaceLabel
;
121 os
<< ", barLength=" << rhs
._barLength
;
122 os
<< ", barHeight=" << rhs
._barHeight
;
123 os
<< ", labelMargin=" << rhs
._labelMargin
;
124 os
<< ", labelColor=" << rhs
._labelColor
[0] << ',' << rhs
._labelColor
[1]
125 << ',' << rhs
._labelColor
[2] << endl
;
126 os
<< ", gridMinWidth=" << rhs
._gridMinWidth
;
127 os
<< ", gridMinDepth=" << rhs
._gridMinDepth
;
132 getColorResource(const char *name
, QString label
, float &r
, float &g
, float &b
)
134 if (label
!= QString::null
&& label
.compare("default") != 0) {
135 const char *str
= (const char *)label
.toLatin1();
136 if (ColorList::findColor(str
, r
, g
, b
) == false) {
137 pmprintf("%s: Unable to map color resource \"%s\" to \"%s\", "
138 "using default color rgbi:%f/%f/%f\n",
139 pmProgname
, name
, str
, r
, g
, b
);
145 DefaultObj::getResources()
149 resources
.beginGroup(pmProgname
);
151 _baseBorderX
= resources
.value("baseBorderWidth", 8).toInt();
152 _baseBorderZ
= resources
.value("baseBorderDepth", 8).toInt();
153 _baseHeight
= resources
.value("baseHeight", 2).toInt();
154 color
= resources
.value("baseColor", QString("default")).toString();
155 getColorResource("baseColor", color
,
156 _baseColor
[0], _baseColor
[1], _baseColor
[2]);
157 _barSpaceX
= resources
.value("barSpaceWidth", 8).toInt();
158 _barSpaceZ
= resources
.value("barSpaceDepth", 8).toInt();
159 _barSpaceLabel
= resources
.value("barSpaceLabel", 6).toInt();
160 _barLength
= resources
.value("barLength", 28).toInt();
161 _barHeight
= resources
.value("barHeight", 80).toInt();
162 _labelMargin
= resources
.value("labelMargin", 5).toInt();
163 color
= resources
.value("labelColor", QString("default")).toString();
164 getColorResource("labelColor", color
,
165 _labelColor
[0], _labelColor
[1], _labelColor
[2]);
166 _gridMinWidth
= resources
.value("gridMinWidth", 20).toInt();
167 _gridMinDepth
= resources
.value("gridMinDepth", 20).toInt();
169 resources
.endGroup();
172 if (pmDebug
& DBG_TRACE_APPL0
)
173 cerr
<< "DefaultObj::getResources: " << *this << endl
;