src/AddObjectDialog.cc

changeset 642
751a8df42842
parent 640
d4dda62c6600
child 644
93dcd1a0e4bd
equal deleted inserted replaced
641:425b169a82aa 642:751a8df42842
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
66 case LDObject::EComment: 66 case LDObject::EComment:
67 { 67 {
68 le_comment = new QLineEdit; 68 le_comment = new QLineEdit;
69 69
70 if (obj) 70 if (obj)
71 le_comment->setText (static_cast<LDComment*> (obj)->text); 71 le_comment->setText (static_cast<LDComment*> (obj)->text());
72 72
73 le_comment->setMinimumWidth (384); 73 le_comment->setMinimumWidth (384);
74 } break; 74 } break;
75 75
76 case LDObject::ELine: 76 case LDObject::ELine:
106 106
107 rb_bfcType->addButton (LDBFC::k_statementStrings[i]); 107 rb_bfcType->addButton (LDBFC::k_statementStrings[i]);
108 } 108 }
109 109
110 if (obj) 110 if (obj)
111 rb_bfcType->setValue ( (int) static_cast<LDBFC*> (obj)->m_statement); 111 rb_bfcType->setValue ( (int) static_cast<LDBFC*> (obj)->statement());
112 } break; 112 } break;
113 113
114 case LDObject::ESubfile: 114 case LDObject::ESubfile:
115 { 115 {
116 coordCount = 3; 116 coordCount = 3;
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 }
144 le_subfileName->setFocus(); 144 le_subfileName->setFocus();
145 145
146 if (obj) 146 if (obj)
147 { 147 {
148 LDSubfile* ref = static_cast<LDSubfile*> (obj); 148 LDSubfile* ref = static_cast<LDSubfile*> (obj);
149 le_subfileName->setText (ref->getFileInfo()->getName()); 149 le_subfileName->setText (ref->fileInfo()->name());
150 } 150 }
151 } break; 151 } break;
152 152
153 default: 153 default:
154 { 154 {
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()
361 switch (type) 361 switch (type)
362 { 362 {
363 case LDObject::EComment: 363 case LDObject::EComment:
364 { 364 {
365 LDComment* comm = initObj<LDComment> (obj); 365 LDComment* comm = initObj<LDComment> (obj);
366 comm->text = dlg.le_comment->text(); 366 comm->setText (dlg.le_comment->text());
367 } 367 }
368 break; 368 break;
369 369
370 case LDObject::ELine: 370 case LDObject::ELine:
371 case LDObject::ETriangle: 371 case LDObject::ETriangle:
387 } break; 387 } break;
388 388
389 case LDObject::EBFC: 389 case LDObject::EBFC:
390 { 390 {
391 LDBFC* bfc = initObj<LDBFC> (obj); 391 LDBFC* bfc = initObj<LDBFC> (obj);
392 bfc->m_statement = (LDBFC::Statement) dlg.rb_bfcType->value(); 392 bfc->setStatement ((LDBFC::Statement) dlg.rb_bfcType->value());
393 } break; 393 } break;
394 394
395 case LDObject::EVertex: 395 case LDObject::EVertex:
396 { 396 {
397 LDVertex* vert = initObj<LDVertex> (obj); 397 LDVertex* vert = initObj<LDVertex> (obj);

mercurial