34 #include "Widgets.h" |
34 #include "Widgets.h" |
35 #include "Misc.h" |
35 #include "Misc.h" |
36 #include "Primitives.h" |
36 #include "Primitives.h" |
37 |
37 |
38 // ============================================================================= |
38 // ============================================================================= |
39 // ============================================================================= |
39 // |
40 class SubfileListItem : public QTreeWidgetItem |
40 class SubfileListItem : public QTreeWidgetItem |
41 { |
41 { |
42 PROPERTY (public, Primitive*, PrimitiveInfo, NO_OPS, STOCK_WRITE) |
42 PROPERTY (public, Primitive*, primitive, setPrimitive, STOCK_WRITE) |
43 |
43 |
44 public: |
44 public: |
45 SubfileListItem (QTreeWidgetItem* parent, Primitive* info) : |
45 SubfileListItem (QTreeWidgetItem* parent, Primitive* info) : |
46 QTreeWidgetItem (parent), |
46 QTreeWidgetItem (parent), |
47 m_PrimitiveInfo (info) {} |
47 m_primitive (info) {} |
48 |
48 |
49 SubfileListItem (QTreeWidget* parent, Primitive* info) : |
49 SubfileListItem (QTreeWidget* parent, Primitive* info) : |
50 QTreeWidgetItem (parent), |
50 QTreeWidgetItem (parent), |
51 m_PrimitiveInfo (info) {} |
51 m_primitive (info) {} |
52 }; |
52 }; |
53 |
53 |
54 // ============================================================================= |
54 // ============================================================================= |
55 // ============================================================================= |
55 // |
56 AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObject* obj, QWidget* parent) : |
56 AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObject* obj, QWidget* parent) : |
57 QDialog (parent) |
57 QDialog (parent) |
58 { |
58 { |
59 setlocale (LC_ALL, "C"); |
59 setlocale (LC_ALL, "C"); |
60 |
60 |
118 tw_subfileList->setHeaderLabel (tr ("Primitives")); |
118 tw_subfileList->setHeaderLabel (tr ("Primitives")); |
119 |
119 |
120 for (PrimitiveCategory* cat : g_PrimitiveCategories) |
120 for (PrimitiveCategory* cat : g_PrimitiveCategories) |
121 { |
121 { |
122 SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, null); |
122 SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, null); |
123 parentItem->setText (0, cat->getName()); |
123 parentItem->setText (0, cat->name()); |
124 QList<QTreeWidgetItem*> subfileItems; |
124 QList<QTreeWidgetItem*> subfileItems; |
125 |
125 |
126 for (Primitive& prim : cat->prims) |
126 for (Primitive& prim : cat->prims) |
127 { |
127 { |
128 SubfileListItem* item = new SubfileListItem (parentItem, &prim); |
128 SubfileListItem* item = new SubfileListItem (parentItem, &prim); |
129 item->setText (0, fmt ("%1 - %2", prim.name, prim.title)); |
129 item->setText (0, fmt ("%1 - %2", prim.name, prim.title)); |
130 subfileItems << item; |
130 subfileItems << item; |
131 |
131 |
132 // If this primitive is the one the current object points to, |
132 // If this primitive is the one the current object points to, |
133 // select it by default |
133 // select it by default |
134 if (obj && static_cast<LDSubfile*> (obj)->getFileInfo()->getName() == prim.name) |
134 if (obj && static_cast<LDSubfile*> (obj)->fileInfo()->name() == prim.name) |
135 tw_subfileList->setCurrentItem (item); |
135 tw_subfileList->setCurrentItem (item); |
136 } |
136 } |
137 |
137 |
138 tw_subfileList->addTopLevelItem (parentItem); |
138 tw_subfileList->addTopLevelItem (parentItem); |
139 } |
139 } |
164 |
164 |
165 // Show a color edit dialog for the types that actually use the color |
165 // Show a color edit dialog for the types that actually use the color |
166 if (defaults->isColored()) |
166 if (defaults->isColored()) |
167 { |
167 { |
168 if (obj != null) |
168 if (obj != null) |
169 colnum = obj->getColor(); |
169 colnum = obj->color(); |
170 else |
170 else |
171 colnum = (type == LDObject::ECondLine || type == LDObject::ELine) ? edgecolor : maincolor; |
171 colnum = (type == LDObject::ECondLine || type == LDObject::ELine) ? edgecolor : maincolor; |
172 |
172 |
173 pb_color = new QPushButton; |
173 pb_color = new QPushButton; |
174 setButtonBackground (pb_color, colnum); |
174 setButtonBackground (pb_color, colnum); |
231 Matrix defaultMatrix = g_identity; |
231 Matrix defaultMatrix = g_identity; |
232 |
232 |
233 if (mo) |
233 if (mo) |
234 { |
234 { |
235 for_axes (ax) |
235 for_axes (ax) |
236 dsb_coords[ax]->setValue (mo->getPosition()[ax]); |
236 dsb_coords[ax]->setValue (mo->position()[ax]); |
237 |
237 |
238 defaultMatrix = mo->getTransform(); |
238 defaultMatrix = mo->transform(); |
239 } |
239 } |
240 |
240 |
241 le_matrix->setText (defaultMatrix.toString()); |
241 le_matrix->setText (defaultMatrix.toString()); |
242 layout->addWidget (lb_matrix, 4, 1); |
242 layout->addWidget (lb_matrix, 4, 1); |
243 layout->addWidget (le_matrix, 4, 2, 1, 3); |
243 layout->addWidget (le_matrix, 4, 2, 1, 3); |
269 |
269 |
270 // ============================================================================= |
270 // ============================================================================= |
271 // ============================================================================= |
271 // ============================================================================= |
272 void AddObjectDialog::setButtonBackground (QPushButton* button, int colnum) |
272 void AddObjectDialog::setButtonBackground (QPushButton* button, int colnum) |
273 { |
273 { |
274 LDColor* col = getColor (colnum); |
274 LDColor* col = ::getColor (colnum); |
275 |
275 |
276 button->setIcon (getIcon ("palette")); |
276 button->setIcon (getIcon ("palette")); |
277 button->setAutoFillBackground (true); |
277 button->setAutoFillBackground (true); |
278 |
278 |
279 if (col) |
279 if (col) |
284 // ============================================================================= |
284 // ============================================================================= |
285 QString AddObjectDialog::currentSubfileName() |
285 QString AddObjectDialog::currentSubfileName() |
286 { |
286 { |
287 SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem()); |
287 SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem()); |
288 |
288 |
289 if (item->getPrimitiveInfo() == null) |
289 if (item->primitive() == null) |
290 return ""; // selected a heading |
290 return ""; // selected a heading |
291 |
291 |
292 return item->getPrimitiveInfo()->name; |
292 return item->primitive()->name; |
293 } |
293 } |
294 |
294 |
295 // ============================================================================= |
295 // ============================================================================= |
296 // ============================================================================= |
296 // ============================================================================= |
297 void AddObjectDialog::slot_colorButtonClicked() |
297 void AddObjectDialog::slot_colorButtonClicked() |