60 int coordCount = 0; |
60 int coordCount = 0; |
61 str typeName = LDObject::typeName (type); |
61 str typeName = LDObject::typeName (type); |
62 |
62 |
63 switch (type) |
63 switch (type) |
64 { case LDObject::Comment: |
64 { case LDObject::Comment: |
65 le_comment = new QLineEdit; |
65 { le_comment = new QLineEdit; |
66 |
66 |
67 if (obj) |
67 if (obj) |
68 le_comment->setText (static_cast<LDComment*> (obj)->text); |
68 le_comment->setText (static_cast<LDComment*> (obj)->text); |
69 |
69 |
70 le_comment->setMinimumWidth (384); |
70 le_comment->setMinimumWidth (384); |
71 break; |
71 } break; |
72 |
72 |
73 case LDObject::Line: |
73 case LDObject::Line: |
74 coordCount = 6; |
74 { coordCount = 6; |
75 break; |
75 } break; |
76 |
76 |
77 case LDObject::Triangle: |
77 case LDObject::Triangle: |
78 coordCount = 9; |
78 { coordCount = 9; |
79 break; |
79 } break; |
80 |
80 |
81 case LDObject::Quad: |
81 case LDObject::Quad: |
82 case LDObject::CondLine: |
82 case LDObject::CondLine: |
83 coordCount = 12; |
83 { coordCount = 12; |
84 break; |
84 } break; |
85 |
85 |
86 case LDObject::Vertex: |
86 case LDObject::Vertex: |
87 coordCount = 3; |
87 { coordCount = 3; |
88 break; |
88 } break; |
89 |
89 |
90 case LDObject::BFC: |
90 case LDObject::BFC: |
91 rb_bfcType = new RadioGroup ("Statement", {}, 0, Qt::Vertical); |
91 { rb_bfcType = new RadioGroup ("Statement", {}, 0, Qt::Vertical); |
92 |
92 |
93 for (int i = 0; i < LDBFC::NumStatements; ++i) |
93 for (int i = 0; i < LDBFC::NumStatements; ++i) |
94 { // Separate these in two columns |
94 { // Separate these in two columns |
95 if (i == LDBFC::NumStatements / 2) |
95 if (i == LDBFC::NumStatements / 2) |
96 rb_bfcType->rowBreak(); |
96 rb_bfcType->rowBreak(); |
98 rb_bfcType->addButton (LDBFC::statements[i]); |
98 rb_bfcType->addButton (LDBFC::statements[i]); |
99 } |
99 } |
100 |
100 |
101 if (obj) |
101 if (obj) |
102 rb_bfcType->setValue ( (int) static_cast<LDBFC*> (obj)->type); |
102 rb_bfcType->setValue ( (int) static_cast<LDBFC*> (obj)->type); |
103 |
103 } break; |
104 break; |
|
105 |
104 |
106 case LDObject::Subfile: |
105 case LDObject::Subfile: |
107 coordCount = 3; |
106 { coordCount = 3; |
108 |
|
109 // If the primitive lister is busy writing data, we have to wait |
|
110 // for that to happen first. This should be quite considerably rare. |
|
111 while (isPrimitiveLoaderBusy()) |
|
112 ; |
|
113 |
|
114 tw_subfileList = new QTreeWidget(); |
107 tw_subfileList = new QTreeWidget(); |
115 tw_subfileList->setHeaderLabel (tr ("Primitives")); |
108 tw_subfileList->setHeaderLabel (tr ("Primitives")); |
116 |
109 |
117 for (PrimitiveCategory & cat : g_PrimitiveCategories) |
110 for (PrimitiveCategory* cat : g_PrimitiveCategories) |
118 { SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, null); |
111 { SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, null); |
119 parentItem->setText (0, cat.getName()); |
112 parentItem->setText (0, cat->getName()); |
120 QList<QTreeWidgetItem*> subfileItems; |
113 QList<QTreeWidgetItem*> subfileItems; |
121 |
114 |
122 for (Primitive & prim : cat.prims) |
115 for (Primitive& prim : cat->prims) |
123 { SubfileListItem* item = new SubfileListItem (parentItem, &prim); |
116 { SubfileListItem* item = new SubfileListItem (parentItem, &prim); |
124 item->setText (0, fmt ("%1 - %2", prim.name, prim.title)); |
117 item->setText (0, fmt ("%1 - %2", prim.name, prim.title)); |
125 subfileItems << item; |
118 subfileItems << item; |
126 |
119 |
127 // If this primitive is the one the current object points to, |
120 // If this primitive is the one the current object points to, |
140 |
133 |
141 if (obj) |
134 if (obj) |
142 { LDSubfile* ref = static_cast<LDSubfile*> (obj); |
135 { LDSubfile* ref = static_cast<LDSubfile*> (obj); |
143 le_subfileName->setText (ref->getFileInfo()->getName()); |
136 le_subfileName->setText (ref->getFileInfo()->getName()); |
144 } |
137 } |
145 |
138 } break; |
146 break; |
|
147 |
139 |
148 default: |
140 default: |
149 critical (fmt ("Unhandled LDObject type %1 (%2) in AddObjectDialog", (int) type, typeName)); |
141 { critical (fmt ("Unhandled LDObject type %1 (%2) in AddObjectDialog", (int) type, typeName)); |
150 return; |
142 } return; |
151 } |
143 } |
152 |
144 |
153 QPixmap icon = getIcon (fmt ("add-%1", typeName)); |
145 QPixmap icon = getIcon (fmt ("add-%1", typeName)); |
154 LDObject* defaults = LDObject::getDefault (type); |
146 LDObject* defaults = LDObject::getDefault (type); |
155 |
147 |
346 |
338 |
347 case LDObject::Line: |
339 case LDObject::Line: |
348 case LDObject::Triangle: |
340 case LDObject::Triangle: |
349 case LDObject::Quad: |
341 case LDObject::Quad: |
350 case LDObject::CondLine: |
342 case LDObject::CondLine: |
351 |
343 { if (!obj) |
352 if (!obj) |
|
353 obj = LDObject::getDefault (type); |
344 obj = LDObject::getDefault (type); |
354 |
345 |
355 for (int i = 0; i < obj->vertices(); ++i) |
346 for (int i = 0; i < obj->vertices(); ++i) |
356 { vertex v; |
347 { vertex v; |
357 |
348 |
358 for (const Axis ax : g_Axes) |
349 for (const Axis ax : g_Axes) |
359 v[ax] = dlg.dsb_coords[ (i * 3) + ax]->value(); |
350 v[ax] = dlg.dsb_coords[ (i * 3) + ax]->value(); |
360 |
351 |
361 obj->setVertex (i, v); |
352 obj->setVertex (i, v); |
362 } |
353 } |
363 |
354 } break; |
364 break; |
|
365 |
355 |
366 case LDObject::BFC: |
356 case LDObject::BFC: |
367 { LDBFC* bfc = initObj<LDBFC> (obj); |
357 { LDBFC* bfc = initObj<LDBFC> (obj); |
368 bfc->type = (LDBFC::Type) dlg.rb_bfcType->value(); |
358 bfc->type = (LDBFC::Type) dlg.rb_bfcType->value(); |
369 } |
359 } break; |
370 break; |
|
371 |
360 |
372 case LDObject::Vertex: |
361 case LDObject::Vertex: |
373 { LDVertex* vert = initObj<LDVertex> (obj); |
362 { LDVertex* vert = initObj<LDVertex> (obj); |
374 |
363 |
375 for (const Axis ax : g_Axes) |
364 for (const Axis ax : g_Axes) |
389 { critical (fmt ("Couldn't open `%1': %2", name, strerror (errno))); |
378 { critical (fmt ("Couldn't open `%1': %2", name, strerror (errno))); |
390 return; |
379 return; |
391 } |
380 } |
392 |
381 |
393 LDSubfile* ref = initObj<LDSubfile> (obj); |
382 LDSubfile* ref = initObj<LDSubfile> (obj); |
|
383 assert (ref); |
394 |
384 |
395 for (const Axis ax : g_Axes) |
385 for (const Axis ax : g_Axes) |
396 ref->setCoordinate (ax, dlg.dsb_coords[ax]->value()); |
386 ref->setCoordinate (ax, dlg.dsb_coords[ax]->value()); |
397 |
387 |
398 ref->setTransform (transform); |
388 ref->setTransform (transform); |
399 ref->setFileInfo (file); |
389 ref->setFileInfo (file); |
400 } |
390 } break; |
401 break; |
|
402 |
391 |
403 default: |
392 default: |
404 break; |
393 break; |
405 } |
394 } |
406 |
395 |