62 int coordCount = 0; |
62 int coordCount = 0; |
63 str typeName = LDObject::typeName (type); |
63 str typeName = LDObject::typeName (type); |
64 |
64 |
65 switch (type) |
65 switch (type) |
66 { |
66 { |
67 case LDObject::Comment: |
67 case LDObject::EComment: |
68 { |
68 { |
69 le_comment = new QLineEdit; |
69 le_comment = new QLineEdit; |
70 |
70 |
71 if (obj) |
71 if (obj) |
72 le_comment->setText (static_cast<LDComment*> (obj)->text); |
72 le_comment->setText (static_cast<LDComment*> (obj)->text); |
73 |
73 |
74 le_comment->setMinimumWidth (384); |
74 le_comment->setMinimumWidth (384); |
75 } break; |
75 } break; |
76 |
76 |
77 case LDObject::Line: |
77 case LDObject::ELine: |
78 { |
78 { |
79 coordCount = 6; |
79 coordCount = 6; |
80 } break; |
80 } break; |
81 |
81 |
82 case LDObject::Triangle: |
82 case LDObject::ETriangle: |
83 { |
83 { |
84 coordCount = 9; |
84 coordCount = 9; |
85 } break; |
85 } break; |
86 |
86 |
87 case LDObject::Quad: |
87 case LDObject::EQuad: |
88 case LDObject::CondLine: |
88 case LDObject::ECondLine: |
89 { |
89 { |
90 coordCount = 12; |
90 coordCount = 12; |
91 } break; |
91 } break; |
92 |
92 |
93 case LDObject::Vertex: |
93 case LDObject::EVertex: |
94 { |
94 { |
95 coordCount = 3; |
95 coordCount = 3; |
96 } break; |
96 } break; |
97 |
97 |
98 case LDObject::BFC: |
98 case LDObject::EBFC: |
99 { |
99 { |
100 rb_bfcType = new RadioGroup ("Statement", {}, 0, Qt::Vertical); |
100 rb_bfcType = new RadioGroup ("Statement", {}, 0, Qt::Vertical); |
101 |
101 |
102 for (int i = 0; i < LDBFC::NumStatements; ++i) |
102 for (int i = 0; i < LDBFC::NumStatements; ++i) |
103 { |
103 { |
167 if (defaults->isColored()) |
167 if (defaults->isColored()) |
168 { |
168 { |
169 if (obj != null) |
169 if (obj != null) |
170 colnum = obj->getColor(); |
170 colnum = obj->getColor(); |
171 else |
171 else |
172 colnum = (type == LDObject::CondLine || type == LDObject::Line) ? edgecolor : maincolor; |
172 colnum = (type == LDObject::ECondLine || type == LDObject::ELine) ? edgecolor : maincolor; |
173 |
173 |
174 pb_color = new QPushButton; |
174 pb_color = new QPushButton; |
175 setButtonBackground (pb_color, colnum); |
175 setButtonBackground (pb_color, colnum); |
176 connect (pb_color, SIGNAL (clicked()), this, SLOT (slot_colorButtonClicked())); |
176 connect (pb_color, SIGNAL (clicked()), this, SLOT (slot_colorButtonClicked())); |
177 } |
177 } |
187 QGridLayout* const layout = new QGridLayout; |
187 QGridLayout* const layout = new QGridLayout; |
188 layout->addWidget (lb_typeIcon, 0, 0); |
188 layout->addWidget (lb_typeIcon, 0, 0); |
189 |
189 |
190 switch (type) |
190 switch (type) |
191 { |
191 { |
192 case LDObject::Line: |
192 case LDObject::ELine: |
193 case LDObject::CondLine: |
193 case LDObject::ECondLine: |
194 case LDObject::Triangle: |
194 case LDObject::ETriangle: |
195 case LDObject::Quad: |
195 case LDObject::EQuad: |
196 |
196 |
197 // Apply coordinates |
197 // Apply coordinates |
198 if (obj) |
198 if (obj) |
199 { |
199 { |
200 for (int i = 0; i < coordCount / 3; ++i) |
200 for (int i = 0; i < coordCount / 3; ++i) |
202 dsb_coords[ (i * 3) + j]->setValue (obj->getVertex (i).coord (j)); |
202 dsb_coords[ (i * 3) + j]->setValue (obj->getVertex (i).coord (j)); |
203 } |
203 } |
204 |
204 |
205 break; |
205 break; |
206 |
206 |
207 case LDObject::Comment: |
207 case LDObject::EComment: |
208 layout->addWidget (le_comment, 0, 1); |
208 layout->addWidget (le_comment, 0, 1); |
209 break; |
209 break; |
210 |
210 |
211 case LDObject::BFC: |
211 case LDObject::EBFC: |
212 layout->addWidget (rb_bfcType, 0, 1); |
212 layout->addWidget (rb_bfcType, 0, 1); |
213 break; |
213 break; |
214 |
214 |
215 case LDObject::Subfile: |
215 case LDObject::ESubfile: |
216 layout->addWidget (tw_subfileList, 1, 1, 1, 2); |
216 layout->addWidget (tw_subfileList, 1, 1, 1, 2); |
217 layout->addWidget (lb_subfileName, 2, 1); |
217 layout->addWidget (lb_subfileName, 2, 1); |
218 layout->addWidget (le_subfileName, 2, 2); |
218 layout->addWidget (le_subfileName, 2, 2); |
219 break; |
219 break; |
220 |
220 |
227 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj); |
227 LDMatrixObject* mo = dynamic_cast<LDMatrixObject*> (obj); |
228 |
228 |
229 QLabel* lb_matrix = new QLabel ("Matrix:"); |
229 QLabel* lb_matrix = new QLabel ("Matrix:"); |
230 le_matrix = new QLineEdit; |
230 le_matrix = new QLineEdit; |
231 // le_matrix->setValidator (new QDoubleValidator); |
231 // le_matrix->setValidator (new QDoubleValidator); |
232 matrix defaultMatrix = g_identity; |
232 Matrix defaultMatrix = g_identity; |
233 |
233 |
234 if (mo) |
234 if (mo) |
235 { |
235 { |
236 for_axes (ax) |
236 for_axes (ax) |
237 dsb_coords[ax]->setValue (mo->getPosition()[ax]); |
237 dsb_coords[ax]->setValue (mo->getPosition()[ax]); |
326 void AddObjectDialog::staticDialog (const LDObject::Type type, LDObject* obj) |
326 void AddObjectDialog::staticDialog (const LDObject::Type type, LDObject* obj) |
327 { |
327 { |
328 setlocale (LC_ALL, "C"); |
328 setlocale (LC_ALL, "C"); |
329 |
329 |
330 // FIXME: Redirect to Edit Raw |
330 // FIXME: Redirect to Edit Raw |
331 if (obj && obj->getType() == LDObject::Error) |
331 if (obj && obj->getType() == LDObject::EError) |
332 return; |
332 return; |
333 |
333 |
334 if (type == LDObject::Empty) |
334 if (type == LDObject::EEmpty) |
335 return; // Nothing to edit with empties |
335 return; // Nothing to edit with empties |
336 |
336 |
337 const bool newObject = (obj == null); |
337 const bool newObject = (obj == null); |
338 matrix transform = g_identity; |
338 Matrix transform = g_identity; |
339 AddObjectDialog dlg (type, obj); |
339 AddObjectDialog dlg (type, obj); |
340 |
340 |
341 assert (!obj || obj->getType() == type); |
341 assert (!obj || obj->getType() == type); |
342 |
342 |
343 if (dlg.exec() == false) |
343 if (dlg.exec() == false) |
344 return; |
344 return; |
345 |
345 |
346 if (type == LDObject::Subfile) |
346 if (type == LDObject::ESubfile) |
347 { |
347 { |
348 QStringList matrixstrvals = dlg.le_matrix->text().split (" ", QString::SkipEmptyParts); |
348 QStringList matrixstrvals = dlg.le_matrix->text().split (" ", QString::SkipEmptyParts); |
349 |
349 |
350 if (matrixstrvals.size() == 9) |
350 if (matrixstrvals.size() == 9) |
351 { |
351 { |
353 int i = 0; |
353 int i = 0; |
354 |
354 |
355 for (str val : matrixstrvals) |
355 for (str val : matrixstrvals) |
356 matrixvals[i++] = val.toFloat(); |
356 matrixvals[i++] = val.toFloat(); |
357 |
357 |
358 transform = matrix (matrixvals); |
358 transform = Matrix (matrixvals); |
359 } |
359 } |
360 } |
360 } |
361 |
361 |
362 switch (type) |
362 switch (type) |
363 { |
363 { |
364 case LDObject::Comment: |
364 case LDObject::EComment: |
365 { |
365 { |
366 LDComment* comm = initObj<LDComment> (obj); |
366 LDComment* comm = initObj<LDComment> (obj); |
367 comm->text = dlg.le_comment->text(); |
367 comm->text = dlg.le_comment->text(); |
368 } |
368 } |
369 break; |
369 break; |
370 |
370 |
371 case LDObject::Line: |
371 case LDObject::ELine: |
372 case LDObject::Triangle: |
372 case LDObject::ETriangle: |
373 case LDObject::Quad: |
373 case LDObject::EQuad: |
374 case LDObject::CondLine: |
374 case LDObject::ECondLine: |
375 { |
375 { |
376 if (!obj) |
376 if (!obj) |
377 obj = LDObject::getDefault (type); |
377 obj = LDObject::getDefault (type); |
378 |
378 |
379 for (int i = 0; i < obj->vertices(); ++i) |
379 for (int i = 0; i < obj->vertices(); ++i) |
380 { |
380 { |
381 vertex v; |
381 Vertex v; |
382 |
382 |
383 for_axes (ax) |
383 for_axes (ax) |
384 v[ax] = dlg.dsb_coords[ (i * 3) + ax]->value(); |
384 v[ax] = dlg.dsb_coords[ (i * 3) + ax]->value(); |
385 |
385 |
386 obj->setVertex (i, v); |
386 obj->setVertex (i, v); |
387 } |
387 } |
388 } break; |
388 } break; |
389 |
389 |
390 case LDObject::BFC: |
390 case LDObject::EBFC: |
391 { |
391 { |
392 LDBFC* bfc = initObj<LDBFC> (obj); |
392 LDBFC* bfc = initObj<LDBFC> (obj); |
393 bfc->type = (LDBFC::Type) dlg.rb_bfcType->value(); |
393 bfc->type = (LDBFC::Type) dlg.rb_bfcType->value(); |
394 } break; |
394 } break; |
395 |
395 |
396 case LDObject::Vertex: |
396 case LDObject::EVertex: |
397 { |
397 { |
398 LDVertex* vert = initObj<LDVertex> (obj); |
398 LDVertex* vert = initObj<LDVertex> (obj); |
399 |
399 |
400 for_axes (ax) |
400 for_axes (ax) |
401 vert->pos[ax] = dlg.dsb_coords[ax]->value(); |
401 vert->pos[ax] = dlg.dsb_coords[ax]->value(); |
402 } |
402 } |
403 break; |
403 break; |
404 |
404 |
405 case LDObject::Subfile: |
405 case LDObject::ESubfile: |
406 { |
406 { |
407 str name = dlg.le_subfileName->text(); |
407 str name = dlg.le_subfileName->text(); |
408 |
408 |
409 if (name.length() == 0) |
409 if (name.length() == 0) |
410 return; // no subfile filename |
410 return; // no subfile filename |