37 #include "moc_addObjectDialog.cpp" |
37 #include "moc_addObjectDialog.cpp" |
38 |
38 |
39 // ============================================================================= |
39 // ============================================================================= |
40 // ----------------------------------------------------------------------------- |
40 // ----------------------------------------------------------------------------- |
41 class SubfileListItem : public QTreeWidgetItem |
41 class SubfileListItem : public QTreeWidgetItem |
42 { PROPERTY (Primitive*, primInfo, setPrimInfo) |
42 { PROPERTY (public, Primitive*, PrimitiveInfo, NO_OPS, NO_CB) |
43 |
43 |
44 public: |
44 public: |
45 SubfileListItem (QTreeWidgetItem* parent, Primitive* info) : |
45 SubfileListItem (QTreeWidgetItem* parent, Primitive* info) : |
46 QTreeWidgetItem (parent), m_primInfo (info) {} |
46 QTreeWidgetItem (parent), |
|
47 m_PrimitiveInfo (info) {} |
|
48 |
47 SubfileListItem (QTreeWidget* parent, Primitive* info) : |
49 SubfileListItem (QTreeWidget* parent, Primitive* info) : |
48 QTreeWidgetItem (parent), m_primInfo (info) {} |
50 QTreeWidgetItem (parent), |
|
51 m_PrimitiveInfo (info) {} |
49 }; |
52 }; |
50 |
53 |
51 // ============================================================================= |
54 // ============================================================================= |
52 // ----------------------------------------------------------------------------- |
55 // ----------------------------------------------------------------------------- |
53 AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObject* obj, QWidget* parent) : QDialog (parent) |
56 AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObject* obj, QWidget* parent) : |
|
57 QDialog (parent) |
54 { setlocale (LC_ALL, "C"); |
58 { setlocale (LC_ALL, "C"); |
55 |
59 |
56 int coordCount = 0; |
60 int coordCount = 0; |
57 str typeName = LDObject::typeName (type); |
61 str typeName = LDObject::typeName (type); |
58 |
62 |
110 tw_subfileList = new QTreeWidget(); |
114 tw_subfileList = new QTreeWidget(); |
111 tw_subfileList->setHeaderLabel (tr ("Primitives")); |
115 tw_subfileList->setHeaderLabel (tr ("Primitives")); |
112 |
116 |
113 for (PrimitiveCategory & cat : g_PrimitiveCategories) |
117 for (PrimitiveCategory & cat : g_PrimitiveCategories) |
114 { SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, null); |
118 { SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, null); |
115 parentItem->setText (0, cat.name()); |
119 parentItem->setText (0, cat.getName()); |
116 QList<QTreeWidgetItem*> subfileItems; |
120 QList<QTreeWidgetItem*> subfileItems; |
117 |
121 |
118 for (Primitive & prim : cat.prims) |
122 for (Primitive & prim : cat.prims) |
119 { SubfileListItem* item = new SubfileListItem (parentItem, &prim); |
123 { SubfileListItem* item = new SubfileListItem (parentItem, &prim); |
120 item->setText (0, fmt ("%1 - %2", prim.name, prim.title)); |
124 item->setText (0, fmt ("%1 - %2", prim.name, prim.title)); |
121 subfileItems << item; |
125 subfileItems << item; |
122 |
126 |
123 // If this primitive is the one the current object points to, |
127 // If this primitive is the one the current object points to, |
124 // select it by default |
128 // select it by default |
125 if (obj && static_cast<LDSubfile*> (obj)->fileInfo()->name() == prim.name) |
129 if (obj && static_cast<LDSubfile*> (obj)->getFileInfo()->getName() == prim.name) |
126 tw_subfileList->setCurrentItem (item); |
130 tw_subfileList->setCurrentItem (item); |
127 } |
131 } |
128 |
132 |
129 tw_subfileList->addTopLevelItem (parentItem); |
133 tw_subfileList->addTopLevelItem (parentItem); |
130 } |
134 } |
153 lb_typeIcon->setPixmap (icon); |
157 lb_typeIcon->setPixmap (icon); |
154 |
158 |
155 // Show a color edit dialog for the types that actually use the color |
159 // Show a color edit dialog for the types that actually use the color |
156 if (defaults->isColored()) |
160 if (defaults->isColored()) |
157 { if (obj != null) |
161 { if (obj != null) |
158 colnum = obj->color(); |
162 colnum = obj->getColor(); |
159 else |
163 else |
160 colnum = (type == LDObject::CndLine || type == LDObject::Line) ? edgecolor : maincolor; |
164 colnum = (type == LDObject::CndLine || type == LDObject::Line) ? edgecolor : maincolor; |
161 |
165 |
162 pb_color = new QPushButton; |
166 pb_color = new QPushButton; |
163 setButtonBackground (pb_color, colnum); |
167 setButtonBackground (pb_color, colnum); |
217 |
221 |
218 if (mo) |
222 if (mo) |
219 { for (const Axis ax : g_Axes) |
223 { for (const Axis ax : g_Axes) |
220 dsb_coords[ax]->setValue (mo->position() [ax]); |
224 dsb_coords[ax]->setValue (mo->position() [ax]); |
221 |
225 |
222 defaultMatrix = mo->transform(); |
226 defaultMatrix = mo->getTransform(); |
223 } |
227 } |
224 |
228 |
225 le_matrix->setText (defaultMatrix.stringRep()); |
229 le_matrix->setText (defaultMatrix.stringRep()); |
226 layout->addWidget (lb_matrix, 4, 1); |
230 layout->addWidget (lb_matrix, 4, 1); |
227 layout->addWidget (le_matrix, 4, 2, 1, 3); |
231 layout->addWidget (le_matrix, 4, 2, 1, 3); |
265 // ============================================================================= |
269 // ============================================================================= |
266 // ----------------------------------------------------------------------------- |
270 // ----------------------------------------------------------------------------- |
267 str AddObjectDialog::currentSubfileName() |
271 str AddObjectDialog::currentSubfileName() |
268 { SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem()); |
272 { SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem()); |
269 |
273 |
270 if (item->primInfo() == null) |
274 if (item->getPrimitiveInfo() == null) |
271 return ""; // selected a heading |
275 return ""; // selected a heading |
272 |
276 |
273 return item->primInfo()->name; |
277 return item->getPrimitiveInfo()->name; |
274 } |
278 } |
275 |
279 |
276 // ============================================================================= |
280 // ============================================================================= |
277 // ----------------------------------------------------------------------------- |
281 // ----------------------------------------------------------------------------- |
278 void AddObjectDialog::slot_colorButtonClicked() |
282 void AddObjectDialog::slot_colorButtonClicked() |