Rev 1770 | Rev 4430 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1770 | cbradney | 1 | #include <qimage.h> |
2 | #include <qlayout.h> |
||
3 | #include <qpopupmenu.h> |
||
3328 | avox | 4 | #include <qbitmap.h> |
1770 | cbradney | 5 | #include <qpixmap.h> |
6 | #include <qbuttongroup.h> |
||
7 | |||
8 | #include "autoformbuttongroup.h" |
||
9 | #include "autoformbuttongroup.moc" |
||
10 | #include "fpointarray.h" |
||
11 | #include "scpainter.h" |
||
12 | |||
13 | AutoformButtonGroup::AutoformButtonGroup( QWidget* parent ) : QButtonGroup( parent, "autoformbuttongroup" ) |
||
14 | { |
||
15 | this->setExclusive( true ); |
||
16 | this->setColumnLayout(0, Qt::Vertical ); |
||
17 | this->layout()->setSpacing( 0 ); |
||
18 | this->layout()->setMargin( 0 ); |
||
19 | buttonGroup1Layout = new QGridLayout( this->layout() ); |
||
20 | buttonGroup1Layout->setAlignment( Qt::AlignTop ); |
||
21 | toolButton1 = new QToolButton( this, "toolButton1" ); |
||
22 | toolButton1->setToggleButton( true ); |
||
23 | toolButton1->setPixmap(getIconPixmap(0)); |
||
24 | buttonGroup1Layout->addWidget( toolButton1, 0, 0 ); |
||
25 | toolButton2 = new QToolButton( this, "toolButton2" ); |
||
26 | toolButton2->setToggleButton( true ); |
||
27 | toolButton2->setPixmap(getIconPixmap(1)); |
||
28 | buttonGroup1Layout->addWidget( toolButton2, 0, 1 ); |
||
29 | toolButton3 = new QToolButton( this, "toolButton3" ); |
||
30 | toolButton3->setToggleButton( true ); |
||
31 | toolButton3->setPixmap(getIconPixmap(2)); |
||
32 | buttonGroup1Layout->addWidget( toolButton3, 0, 2 ); |
||
33 | toolButton4 = new QToolButton( this, "toolButton4" ); |
||
34 | toolButton4->setToggleButton( true ); |
||
35 | toolButton4->setPixmap(getIconPixmap(3)); |
||
36 | buttonGroup1Layout->addWidget( toolButton4, 0, 3 ); |
||
37 | |||
38 | toolButton5 = new QToolButton( this, "toolButton3" ); |
||
39 | toolButton5->setToggleButton( true ); |
||
40 | toolButton5->setPixmap(getIconPixmap(4)); |
||
41 | buttonGroup1Layout->addWidget( toolButton5, 1, 0 ); |
||
42 | toolButton6 = new QToolButton( this, "toolButton4" ); |
||
43 | toolButton6->setToggleButton( true ); |
||
44 | toolButton6->setPixmap(getIconPixmap(5)); |
||
45 | buttonGroup1Layout->addWidget( toolButton6, 1, 1 ); |
||
46 | toolButton7 = new QToolButton( this, "toolButton3" ); |
||
47 | toolButton7->setToggleButton( true ); |
||
48 | toolButton7->setPixmap(getIconPixmap(6)); |
||
49 | buttonGroup1Layout->addWidget( toolButton7, 1, 2 ); |
||
50 | toolButton8 = new QToolButton( this, "toolButton4" ); |
||
51 | toolButton8->setToggleButton( true ); |
||
52 | toolButton8->setPixmap(getIconPixmap(7)); |
||
53 | buttonGroup1Layout->addWidget( toolButton8, 1, 3 ); |
||
54 | |||
55 | toolButton9 = new QToolButton( this, "toolButton4" ); |
||
56 | toolButton9->setToggleButton( true ); |
||
57 | toolButton9->setPixmap(getIconPixmap(8)); |
||
58 | buttonGroup1Layout->addWidget( toolButton9, 2, 0 ); |
||
59 | toolButton10 = new QToolButton( this, "toolButton4" ); |
||
60 | toolButton10->setToggleButton( true ); |
||
61 | toolButton10->setPixmap(getIconPixmap(9)); |
||
62 | buttonGroup1Layout->addWidget( toolButton10, 2, 1 ); |
||
63 | toolButton11 = new QToolButton( this, "toolButton4" ); |
||
64 | toolButton11->setToggleButton( true ); |
||
65 | toolButton11->setPixmap(getIconPixmap(10)); |
||
66 | buttonGroup1Layout->addWidget( toolButton11, 2, 2 ); |
||
67 | toolButton12 = new QToolButton( this, "toolButton4" ); |
||
68 | toolButton12->setToggleButton( true ); |
||
69 | toolButton12->setPixmap(getIconPixmap(11)); |
||
70 | buttonGroup1Layout->addWidget( toolButton12, 2, 3 ); |
||
71 | |||
72 | toolButton13 = new QToolButton( this, "toolButton4" ); |
||
73 | toolButton13->setToggleButton( true ); |
||
74 | toolButton13->setPixmap(getIconPixmap(12)); |
||
75 | buttonGroup1Layout->addWidget( toolButton13, 3, 0 ); |
||
76 | toolButton14 = new QToolButton( this, "toolButton4" ); |
||
77 | toolButton14->setToggleButton( true ); |
||
78 | toolButton14->setPixmap(getIconPixmap(13)); |
||
79 | buttonGroup1Layout->addWidget( toolButton14, 3, 1 ); |
||
80 | toolButton15 = new QToolButton( this, "toolButton4" ); |
||
81 | toolButton15->setToggleButton( true ); |
||
82 | toolButton15->setPixmap(getIconPixmap(14)); |
||
83 | buttonGroup1Layout->addWidget( toolButton15, 3, 2 ); |
||
84 | toolButton16 = new QToolButton( this, "toolButton4" ); |
||
85 | toolButton16->setToggleButton( true ); |
||
86 | toolButton16->setPixmap(getIconPixmap(15)); |
||
87 | buttonGroup1Layout->addWidget( toolButton16, 3, 3 ); |
||
88 | |||
89 | toolButton17 = new QToolButton( this, "toolButton4" ); |
||
90 | toolButton17->setToggleButton( true ); |
||
91 | toolButton17->setPixmap(getIconPixmap(16)); |
||
92 | buttonGroup1Layout->addWidget( toolButton17, 4, 0 ); |
||
93 | toolButton18 = new QToolButton( this, "toolButton4" ); |
||
94 | toolButton18->setToggleButton( true ); |
||
95 | toolButton18->setPixmap(getIconPixmap(17)); |
||
96 | buttonGroup1Layout->addWidget( toolButton18, 4, 1 ); |
||
97 | |||
98 | connect(this, SIGNAL(clicked(int)), this, SLOT(selForm(int))); |
||
99 | |||
100 | } |
||
101 | |||
102 | double* AutoformButtonGroup::getShapeData(int a, int *n) |
||
103 | { |
||
104 | double *vals; |
||
105 | static double AutoShapes0[] = {0.0, 0.0, 0.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, |
||
106 | 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 0.0, 100.0, 0.0, 100.0, |
||
107 | 0.0, 100.0, 0.0, 100.0, 0.0, 0.0, 0.0, 0.0}; |
||
108 | static double AutoShapes1[] = {100.0, 50.0, 100.0, 77.615235, 50.0, 100.0, |
||
109 | 77.615235, 100.0, 50.0, 100.0, |
||
110 | 22.385765, 100.0, |
||
111 | 0.0, 50.0, 0.0, 77.615235, 0.0, 50.0, 0.0, 22.385765, 50.0, 0.0, |
||
112 | 22.385765, 0.0, |
||
113 | 50.0, 0.0, 77.615235, 0.0, 100.0, 50.0, 100.0, 22.385765}; |
||
114 | static double AutoShapes2[] = {0.0, 0.0, 0.0, 0.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, |
||
115 | 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 0.0, 0.0, 0.0}; |
||
116 | static double AutoShapes3[] = {0.0, 25.0, 0.0, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0, 25.0, |
||
117 | 25.0, 0.0, 25.0, 0.0, 25.0, 0.0, 25.0, 0.0, 75.0, 0.0, 75.0, 0.0, |
||
118 | 75.0, 0.0, 75.0, 0.0, 75.0, 25.0, 75.0, 25.0, 75.0, 25.0, 75.0, 25.0, |
||
119 | 100.0, 25.0, 100.0, 25.0, 100.0, 25.0, 100.0, 25.0, 100.0, 75.0, 100.0, 75.0, |
||
120 | 100.0, 75.0, 100.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, 75.0, |
||
121 | 75.0, 100.0, 75.0, 100.0, 75.0, 100.0, 75.0, 100.0, 25.0, 100.0, 25.0, 100.0, |
||
122 | 25.0, 100.0, 25.0, 100.0, 25.0, 75.0, 25.0, 75.0, 25.0, 75.0, 25.0, 75.0, |
||
123 | 0.0, 75.0, 0.0, 75.0, 0.0, 75.0, 0.0, 75.0, 0.0, 25.0, 0.0, 25.0}; |
||
124 | static double AutoShapes4[] = {0.0, 50.0, 0.0, 50.0, 50.0, 0.0, 50.0, 0.0, 50.0, 0.0, 50.0, 0.0, |
||
125 | 50.0, 25.0, 50.0, 25.0, 50.0, 25.0, 50.0, 25.0, 100.0, 25.0, 100.0, 25.0, |
||
126 | 100.0, 25.0, 100.0, 25.0, 100.0, 75.0, 100.0, 75.0, 100.0, 75.0, 100.0, 75.0, |
||
127 | 50.0, 75.0, 50.0, 75.0, 50.0, 75.0, 50.0, 75.0, 50.0, 100.0, 50.0, 100.0, |
||
128 | 50.0, 100.0, 50.0, 100.0, 0.0, 50.0, 0.0, 50.0}; |
||
129 | static double AutoShapes5[] = {0.0, 25.0, 0.0, 25.0, 50.0, 25.0, 50.0, 25.0, 50.0, 25.0, 50.0, 25.0, |
||
130 | 50.0, 0.0, 50.0, 0.0, 50.0, 0.0, 50.0, 0.0, 100.0, 50.0, 100.0, 50.0, |
||
131 | 100.0, 50.0, 100.0, 50.0, 50.0, 100.0, 50.0, 100.0, 50.0, 100.0, 50.0, 100.0, |
||
132 | 50.0, 75.0, 50.0, 75.0, 50.0, 75.0, 50.0, 75.0, 0.0, 75.0, 0.0, 75.0, |
||
133 | 0.0, 75.0, 0.0, 75.0, 0.0, 25.0, 0.0, 25.0}; |
||
134 | static double AutoShapes6[] = {0.0, 50.0, 0.0, 50.0, 50.0, 0.0, 50.0, 0.0, 50.0, 0.0, 50.0, 0.0, |
||
135 | 100.0, 50.0, 100.0, 50.0, 100.0, 50.0, 100.0, 50.0, 75.0, 50.0, 75.0, 50.0, |
||
136 | 75.0, 50.0, 75.0, 50.0, 75.0, 100.0, 75.0, 100.0, 75.0, 100.0, 75.0, 100.0, |
||
137 | 25.0, 100.0, 25.0, 100.0, 25.0, 100.0, 25.0, 100.0, 25.0, 50.0, 25.0, 50.0, |
||
138 | 25.0, 50.0, 25.0, 50.0, 0.0, 50.0, 0.0, 50.0}; |
||
139 | static double AutoShapes7[] = {0.0, 50.0, 0.0, 50.0, 25.0, 50.0, 25.0, 50.0, 25.0, 50.0, 25.0, 50.0, |
||
140 | 25.0, 0.0, 25.0, 0.0, 25.0, 0.0, 25.0, 0.0, 75.0, 0.0, 75.0, 0.0, |
||
141 | 75.0, 0.0, 75.0, 0.0, 75.0, 50.0, 75.0, 50.0, 75.0, 50.0, 75.0, 50.0, |
||
142 | 100.0, 50.0, 100.0, 50.0, 100.0, 50.0, 100.0, 50.0, 50.0, 100.0, 50.0, 100.0, |
||
143 | 50.0, 100.0, 50.0, 100.0, 0.0, 50.0, 0.0, 50.0}; |
||
144 | static double AutoShapes8[] = {0.0, 50.0, 0.0, 22.385765, 100.0, 0.0, 44.77716, 0.0, 100.0, 0.0, 100.0, 0.0, |
||
145 | 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 44.77716, 100.0, 0.0, 50.0, |
||
146 | 0.0, 77.615235}; |
||
147 | static double AutoShapes9[] = {100.0, 50.0, 100.0, 77.615235, 0.0, 100.0, |
||
148 | 55.22284, 100.0, 0.0, 100.0, 0.0, 100.0, |
||
149 | 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 55.22281, 0.0, 100.0, 50.0, 100.0, 22.385765}; |
||
150 | static double AutoShapes10[] = {100.0, 100.0, 100.0, 100.0, 0.0, 100.0, 0.0, |
||
151 | 100.0, 0.0, 100.0, 0.0, 44.7715, |
||
152 | 50.0, 0.0, 22.3858, 0.0, 50.0, 0.0, 77.6152, 0.0, 100.0, 100.0, 100.0, |
||
153 | 44.7715}; |
||
154 | static double AutoShapes11[] = {100.0, 0.0, 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 55.2285, 50.0, 100.0, |
||
155 | 22.3858, 100.0, 50.0, 100.0, 77.6152, 100.0, 100.0, 0.0, 100.0, 55.2285}; |
||
156 | static double AutoShapes12[] = {0.0, 50.0, 0.0, 50.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, |
||
157 | 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 0.0, 50.0, 0.0, 50.0}; |
||
158 | static double AutoShapes13[] = {0.0, 0.0, 0.0, 0.0, 100.0, 50.0, 100.0, 50.0, 100.0, 50.0, 100.0, 50.0, |
||
159 | 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 0.0, 0.0, 0.0}; |
||
160 | static double AutoShapes14[] = {0.0, 100.0, 0.0, 100.0, 50.0, 0.0, 50.0, 0.0, 50.0, 0.0, 50.0, 0.0, |
||
161 | 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 0.0, 100.0, 0.0, 100.0}; |
||
162 | static double AutoShapes15[] = {0.0, 0.0, 0.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, 100.0, 0.0, |
||
163 | 50.0, 100.0, 50.0, 100.0, 50.0, 100.0, 50.0, 100.0, 0.0, 0.0, 0.0, 0.0}; |
||
164 | static double AutoShapes16[] = {25.0, 0.0, 25.0, 0.0, 75.0, 0.0, 75.0, 0.0, 75.0, 0.0, 75.0, 13.8071, |
||
165 | 100.0, 25.0, 86.1929, 25.0, 100.0, 25.0, 100.0, 25.0, 100.0, 75.0, 100.0, 75.0, |
||
166 | 100.0, 75.0, 86.1929, 75.0, 75.0, 100.0, 75.0, 86.1929, 75.0, 100.0, 75.0, 100.0, |
||
167 | 25.0, 100.0, 25.0, 100.0, 25.0, 100.0, 25.0, 86.1929, 0.0, 75.0, 13.8071, 75.0, |
||
168 | 0.0, 75.0, 0.0, 75.0, 0.0, 25.0, 0.0, 25.0, 0.0, 25.0, 13.8071, 25.0, |
||
169 | 25.0, 0.0, 25.0, 13.8071}; |
||
170 | static double AutoShapes17[] = {100.0, 50.0, 100.0, 77.6152, 50.0, 100.0, 77.6152, 100.0, 50.0, 100.0, 22.3858, 100.0, |
||
171 | 0.0, 50.0, 0.0, 77.6152, 0.0, 50.0, 0.0, 22.3858, 50.0, 0.0, 22.3858, 0.0, |
||
172 | 50.0, 0.0, 77.6152, 0.0, 100.0, 50.0, 100.0, 22.3858, -1.0, -1.0, -1.0, -1.0, |
||
173 | 75.0, 50.0, 75.0, 63.8076, 50.0, 75.0, 63.8076, 75.0, 50.0, 75.0, 36.1929, 75.0, |
||
174 | 25.0, 50.0, 25.0, 63.8076, 25.0, 50.0, 25.0, 36.1929, 50.0, 25.0, 36.1929, 25.0, |
||
175 | 50.0, 25.0, 63.8076, 25.0, 75.0, 50.0, 75.0, 36.1929}; |
||
176 | switch (a) |
||
177 | { |
||
178 | case 0: |
||
179 | *n = 32; |
||
180 | vals = AutoShapes0; |
||
181 | break; |
||
182 | case 1: |
||
183 | *n = 32; |
||
184 | vals = AutoShapes1; |
||
185 | break; |
||
186 | case 2: |
||
187 | *n = 24; |
||
188 | vals = AutoShapes2; |
||
189 | break; |
||
190 | case 3: |
||
191 | *n = 96; |
||
192 | vals = AutoShapes3; |
||
193 | break; |
||
194 | case 4: |
||
195 | *n = 56; |
||
196 | vals = AutoShapes4; |
||
197 | break; |
||
198 | case 5: |
||
199 | *n = 56; |
||
200 | vals = AutoShapes5; |
||
201 | break; |
||
202 | case 6: |
||
203 | *n = 56; |
||
204 | vals = AutoShapes6; |
||
205 | break; |
||
206 | case 7: |
||
207 | *n = 56; |
||
208 | vals = AutoShapes7; |
||
209 | break; |
||
210 | case 8: |
||
211 | *n = 24; |
||
212 | vals = AutoShapes8; |
||
213 | break; |
||
214 | case 9: |
||
215 | *n = 24; |
||
216 | vals = AutoShapes9; |
||
217 | break; |
||
218 | case 10: |
||
219 | *n = 24; |
||
220 | vals = AutoShapes10; |
||
221 | break; |
||
222 | case 11: |
||
223 | *n = 24; |
||
224 | vals = AutoShapes11; |
||
225 | break; |
||
226 | case 12: |
||
227 | *n = 24; |
||
228 | vals = AutoShapes12; |
||
229 | break; |
||
230 | case 13: |
||
231 | *n = 24; |
||
232 | vals = AutoShapes13; |
||
233 | break; |
||
234 | case 14: |
||
235 | *n = 24; |
||
236 | vals = AutoShapes14; |
||
237 | break; |
||
238 | case 15: |
||
239 | *n = 24; |
||
240 | vals = AutoShapes15; |
||
241 | break; |
||
242 | case 16: |
||
243 | *n = 64; |
||
244 | vals = AutoShapes16; |
||
245 | break; |
||
246 | case 17: |
||
247 | *n = 68; |
||
248 | vals = AutoShapes17; |
||
249 | break; |
||
250 | } |
||
251 | return vals; |
||
252 | } |
||
253 | |||
254 | void AutoformButtonGroup::selForm(int a) |
||
255 | { |
||
256 | int n; |
||
257 | |||
258 | double* AutoShapes; |
||
259 | AutoShapes = getShapeData(a, &n); |
||
260 | emit FormSel(a, n, AutoShapes); |
||
261 | } |
||
262 | |||
263 | QPixmap AutoformButtonGroup::getIconPixmap(int nr) |
||
264 | { |
||
265 | int count = 0; |
||
266 | double* AutoShapes; |
||
267 | FPointArray Path; |
||
268 | QPixmap Ico(22, 22); |
||
269 | Path.resize(0); |
||
270 | AutoShapes = getShapeData(nr, &count); |
||
271 | for (int a = 0; a < count-3; a += 4) |
||
272 | { |
||
273 | if (AutoShapes[a] < 0) |
||
274 | { |
||
275 | Path.setMarker(); |
||
276 | continue; |
||
277 | } |
||
278 | double x1 = 16 * AutoShapes[a] / 100.0; |
||
279 | double y1 = 16 * AutoShapes[a+1] / 100.0; |
||
280 | double x2 = 16 * AutoShapes[a+2] / 100.0; |
||
281 | double y2 = 16 * AutoShapes[a+3] / 100.0; |
||
282 | Path.addPoint(x1, y1); |
||
283 | Path.addPoint(x2, y2); |
||
284 | } |
||
285 | ScPainter *painter = new ScPainter(&Ico, 22, 22); |
||
3328 | avox | 286 | painter->setBrush(qRgb(255, 255, 255)); |
1770 | cbradney | 287 | painter->setPen(qRgb(0, 0, 0)); |
288 | painter->setFillMode(1); |
||
289 | painter->translate(3.0, 3.0); |
||
290 | painter->setupPolygon(&Path); |
||
291 | painter->setLineWidth(1.0); |
||
292 | painter->drawPolygon(); |
||
293 | painter->drawPolyLine(); |
||
294 | painter->end(); |
||
295 | delete painter; |
||
3328 | avox | 296 | Ico.setMask( Ico.createHeuristicMask() ); |
297 | |||
1770 | cbradney | 298 | return Ico; |
299 | } |