28 #include "setContentsDialog.h" |
28 #include "setContentsDialog.h" |
29 |
29 |
30 #define APPLY_COORDS(OBJ, N) \ |
30 #define APPLY_COORDS(OBJ, N) \ |
31 for (short i = 0; i < N; ++i) \ |
31 for (short i = 0; i < N; ++i) \ |
32 for (const Axis ax : g_Axes) \ |
32 for (const Axis ax : g_Axes) \ |
33 OBJ->vaCoords[i][ax] = dlg.dsb_coords[(i * 3) + ax]->value (); |
33 OBJ->coords[i][ax] = dlg.dsb_coords[(i * 3) + ax]->value (); |
34 |
34 |
35 // ============================================================================= |
35 // ============================================================================= |
36 class SubfileListItem : public QTreeWidgetItem { |
36 class SubfileListItem : public QTreeWidgetItem { |
37 public: |
37 public: |
38 SubfileListItem (QTreeWidgetItem* parent, int subfileID) : |
38 SubfileListItem (QTreeWidgetItem* parent, int subfileID) : |
135 le_subfileName = new QLineEdit; |
135 le_subfileName = new QLineEdit; |
136 le_subfileName->setFocus (); |
136 le_subfileName->setFocus (); |
137 |
137 |
138 if (obj) { |
138 if (obj) { |
139 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
139 LDSubfile* ref = static_cast<LDSubfile*> (obj); |
140 le_subfileName->setText (ref->zFileName); |
140 le_subfileName->setText (ref->fileName); |
141 } |
141 } |
142 break; |
142 break; |
143 |
143 |
144 case LDObject::Radial: |
144 case LDObject::Radial: |
145 coordCount = 3; |
145 coordCount = 3; |
169 sb_radRingNum->setEnabled (false); |
169 sb_radRingNum->setEnabled (false); |
170 |
170 |
171 if (obj) { |
171 if (obj) { |
172 LDRadial* rad = static_cast<LDRadial*> (obj); |
172 LDRadial* rad = static_cast<LDRadial*> (obj); |
173 |
173 |
174 rb_radType->setValue (rad->eRadialType); |
174 rb_radType->setValue (rad->radType); |
175 sb_radSegments->setValue (rad->dSegments); |
175 sb_radSegments->setValue (rad->segs); |
176 cb_radHiRes->setChecked ((rad->dDivisions == 48) ? Qt::Checked : Qt::Unchecked); |
176 cb_radHiRes->setChecked ((rad->divs == 48) ? Qt::Checked : Qt::Unchecked); |
177 sb_radRingNum->setValue (rad->dRingNum); |
177 sb_radRingNum->setValue (rad->ringNum); |
178 } |
178 } |
179 break; |
179 break; |
180 |
180 |
181 default: |
181 default: |
182 assert (false); |
182 assert (false); |
190 lb_typeIcon->setPixmap (icon); |
190 lb_typeIcon->setPixmap (icon); |
191 |
191 |
192 // Show a color edit dialog for the types that actually use the color |
192 // Show a color edit dialog for the types that actually use the color |
193 if (defaults->isColored ()) { |
193 if (defaults->isColored ()) { |
194 if (obj != null) |
194 if (obj != null) |
195 dColor = obj->dColor; |
195 dColor = obj->color; |
196 else |
196 else |
197 dColor = (type == LDObject::CondLine || type == LDObject::Line) ? edgecolor : maincolor; |
197 dColor = (type == LDObject::CondLine || type == LDObject::Line) ? edgecolor : maincolor; |
198 |
198 |
199 pb_color = new QPushButton; |
199 pb_color = new QPushButton; |
200 setButtonBackground (pb_color, dColor); |
200 setButtonBackground (pb_color, dColor); |
220 case LDObject::Quad: |
220 case LDObject::Quad: |
221 // Apply coordinates |
221 // Apply coordinates |
222 if (obj) { |
222 if (obj) { |
223 for (short i = 0; i < coordCount / 3; ++i) |
223 for (short i = 0; i < coordCount / 3; ++i) |
224 for (short j = 0; j < 3; ++j) |
224 for (short j = 0; j < 3; ++j) |
225 dsb_coords[(i * 3) + j]->setValue (obj->vaCoords[i].coord (j)); |
225 dsb_coords[(i * 3) + j]->setValue (obj->coords[i].coord (j)); |
226 } |
226 } |
227 break; |
227 break; |
228 |
228 |
229 case LDObject::Comment: |
229 case LDObject::Comment: |
230 layout->addWidget (le_comment, 0, 1); |
230 layout->addWidget (le_comment, 0, 1); |
242 layout->addWidget (lb_radRingNum, 3, 3); |
242 layout->addWidget (lb_radRingNum, 3, 3); |
243 layout->addWidget (sb_radRingNum, 3, 4); |
243 layout->addWidget (sb_radRingNum, 3, 4); |
244 |
244 |
245 if (obj) |
245 if (obj) |
246 for (short i = 0; i < 3; ++i) |
246 for (short i = 0; i < 3; ++i) |
247 dsb_coords[i]->setValue (static_cast<LDRadial*> (obj)->vPosition.coord (i)); |
247 dsb_coords[i]->setValue (static_cast<LDRadial*> (obj)->pos.coord (i)); |
248 break; |
248 break; |
249 |
249 |
250 case LDObject::Subfile: |
250 case LDObject::Subfile: |
251 layout->addWidget (tw_subfileList, 1, 1, 1, 2); |
251 layout->addWidget (tw_subfileList, 1, 1, 1, 2); |
252 layout->addWidget (lb_subfileName, 2, 1); |
252 layout->addWidget (lb_subfileName, 2, 1); |
253 layout->addWidget (le_subfileName, 2, 2); |
253 layout->addWidget (le_subfileName, 2, 2); |
254 |
254 |
255 if (obj) |
255 if (obj) |
256 for (short i = 0; i < 3; ++i) |
256 for (short i = 0; i < 3; ++i) |
257 dsb_coords[i]->setValue (static_cast<LDSubfile*> (obj)->vPosition.coord (i)); |
257 dsb_coords[i]->setValue (static_cast<LDSubfile*> (obj)->pos.coord (i)); |
258 break; |
258 break; |
259 |
259 |
260 default: |
260 default: |
261 break; |
261 break; |
262 } |
262 } |
267 // le_matrix->setValidator (new QDoubleValidator); |
267 // le_matrix->setValidator (new QDoubleValidator); |
268 matrix<3> defval = g_identity; |
268 matrix<3> defval = g_identity; |
269 |
269 |
270 if (obj) { |
270 if (obj) { |
271 if (obj->getType () == LDObject::Subfile) |
271 if (obj->getType () == LDObject::Subfile) |
272 defval = static_cast<LDSubfile*> (obj)->mMatrix; |
272 defval = static_cast<LDSubfile*> (obj)->transform; |
273 else |
273 else |
274 defval = static_cast<LDRadial*> (obj)->mMatrix; |
274 defval = static_cast<LDRadial*> (obj)->transform; |
275 } |
275 } |
276 |
276 |
277 le_matrix->setText (defval.stringRep ()); |
277 le_matrix->setText (defval.stringRep ()); |
278 layout->addWidget (lb_matrix, 4, 1); |
278 layout->addWidget (lb_matrix, 4, 1); |
279 layout->addWidget (le_matrix, 4, 2, 1, 3); |
279 layout->addWidget (le_matrix, 4, 2, 1, 3); |
409 break; |
409 break; |
410 |
410 |
411 case LDObject::Line: |
411 case LDObject::Line: |
412 { |
412 { |
413 LDLine* line = initObj<LDLine> (obj); |
413 LDLine* line = initObj<LDLine> (obj); |
414 line->dColor = dlg.dColor; |
414 line->color = dlg.dColor; |
415 APPLY_COORDS (line, 2) |
415 APPLY_COORDS (line, 2) |
416 } |
416 } |
417 break; |
417 break; |
418 |
418 |
419 case LDObject::Triangle: |
419 case LDObject::Triangle: |
420 { |
420 { |
421 LDTriangle* tri = initObj<LDTriangle> (obj); |
421 LDTriangle* tri = initObj<LDTriangle> (obj); |
422 tri->dColor = dlg.dColor; |
422 tri->color = dlg.dColor; |
423 APPLY_COORDS (tri, 3) |
423 APPLY_COORDS (tri, 3) |
424 } |
424 } |
425 break; |
425 break; |
426 |
426 |
427 case LDObject::Quad: |
427 case LDObject::Quad: |
428 { |
428 { |
429 LDQuad* quad = initObj<LDQuad> (obj); |
429 LDQuad* quad = initObj<LDQuad> (obj); |
430 quad->dColor = dlg.dColor; |
430 quad->color = dlg.dColor; |
431 APPLY_COORDS (quad, 4) |
431 APPLY_COORDS (quad, 4) |
432 } |
432 } |
433 break; |
433 break; |
434 |
434 |
435 case LDObject::CondLine: |
435 case LDObject::CondLine: |
436 { |
436 { |
437 LDCondLine* line = initObj<LDCondLine> (obj); |
437 LDCondLine* line = initObj<LDCondLine> (obj); |
438 line->dColor = dlg.dColor; |
438 line->color = dlg.dColor; |
439 APPLY_COORDS (line, 4) |
439 APPLY_COORDS (line, 4) |
440 } |
440 } |
441 break; |
441 break; |
442 |
442 |
443 case LDObject::BFC: |
443 case LDObject::BFC: |
448 break; |
448 break; |
449 |
449 |
450 case LDObject::Vertex: |
450 case LDObject::Vertex: |
451 { |
451 { |
452 LDVertex* vert = initObj<LDVertex> (obj); |
452 LDVertex* vert = initObj<LDVertex> (obj); |
453 vert->dColor = dlg.dColor; |
453 vert->color = dlg.dColor; |
454 |
454 |
455 for (const Axis ax : g_Axes) |
455 for (const Axis ax : g_Axes) |
456 vert->vPosition[ax] = dlg.dsb_coords[ax]->value (); |
456 vert->pos[ax] = dlg.dsb_coords[ax]->value (); |
457 } |
457 } |
458 break; |
458 break; |
459 |
459 |
460 case LDObject::Radial: |
460 case LDObject::Radial: |
461 { |
461 { |
462 LDRadial* pRad = initObj<LDRadial> (obj); |
462 LDRadial* pRad = initObj<LDRadial> (obj); |
463 pRad->dColor = dlg.dColor; |
463 pRad->color = dlg.dColor; |
464 |
464 |
465 for (const Axis ax : g_Axes) |
465 for (const Axis ax : g_Axes) |
466 pRad->vPosition[ax] = dlg.dsb_coords[ax]->value (); |
466 pRad->pos[ax] = dlg.dsb_coords[ax]->value (); |
467 |
467 |
468 pRad->dDivisions = (dlg.cb_radHiRes->checkState () != Qt::Checked) ? 16 : 48; |
468 pRad->divs = (dlg.cb_radHiRes->checkState () != Qt::Checked) ? 16 : 48; |
469 pRad->dSegments = min<short> (dlg.sb_radSegments->value (), pRad->dDivisions); |
469 pRad->segs = min<short> (dlg.sb_radSegments->value (), pRad->divs); |
470 pRad->eRadialType = (LDRadial::Type) dlg.rb_radType->value (); |
470 pRad->radType = (LDRadial::Type) dlg.rb_radType->value (); |
471 pRad->dRingNum = dlg.sb_radRingNum->value (); |
471 pRad->ringNum = dlg.sb_radRingNum->value (); |
472 pRad->mMatrix = transform; |
472 pRad->transform = transform; |
473 } |
473 } |
474 break; |
474 break; |
475 |
475 |
476 case LDObject::Subfile: |
476 case LDObject::Subfile: |
477 { |
477 { |
482 OpenFile* file = loadSubfile (name); |
482 OpenFile* file = loadSubfile (name); |
483 if (!file) |
483 if (!file) |
484 return; |
484 return; |
485 |
485 |
486 LDSubfile* ref = initObj<LDSubfile> (obj); |
486 LDSubfile* ref = initObj<LDSubfile> (obj); |
487 ref->dColor = dlg.dColor; |
487 ref->color = dlg.dColor; |
488 |
488 |
489 for (const Axis ax : g_Axes) |
489 for (const Axis ax : g_Axes) |
490 ref->vPosition[ax] = dlg.dsb_coords[ax]->value (); |
490 ref->pos[ax] = dlg.dsb_coords[ax]->value (); |
491 |
491 |
492 ref->zFileName = name; |
492 ref->fileName = name; |
493 ref->mMatrix = transform; |
493 ref->transform = transform; |
494 ref->pFile = file; |
494 ref->fileInfo = file; |
495 } |
495 } |
496 break; |
496 break; |
497 |
497 |
498 default: |
498 default: |
499 break; |
499 break; |