src/gui.cpp

changeset 508
7ace3537a560
parent 504
6a1fa662bfc1
child 515
a0ad72800b96
equal deleted inserted replaced
507:fc76d38c3530 508:7ace3537a560
279 for (int i = 0; i < ui->objectList->count(); ++i) 279 for (int i = 0; i < ui->objectList->count(); ++i)
280 delete ui->objectList->item (i); 280 delete ui->objectList->item (i);
281 281
282 ui->objectList->clear(); 282 ui->objectList->clear();
283 283
284 for (LDObject * obj : LDFile::current()->objects()) 284 for (LDObject* obj : LDFile::current()->objects())
285 { str descr; 285 { str descr;
286 286
287 switch (obj->getType()) 287 switch (obj->getType())
288 { case LDObject::Comment: 288 { case LDObject::Comment:
289 descr = static_cast<LDComment*> (obj)->text; 289 { descr = static_cast<LDComment*> (obj)->text;
290 290
291 // Remove leading whitespace 291 // Remove leading whitespace
292 while (descr[0] == ' ') 292 while (descr[0] == ' ')
293 descr.remove (0, 1); 293 descr.remove (0, 1);
294 294 } break;
295 break;
296 295
297 case LDObject::Empty: 296 case LDObject::Empty:
298 break; // leave it empty 297 break; // leave it empty
299 298
300 case LDObject::Line: 299 case LDObject::Line:
301 case LDObject::Triangle: 300 case LDObject::Triangle:
302 case LDObject::Quad: 301 case LDObject::Quad:
303 case LDObject::CndLine: 302 case LDObject::CndLine:
304 303 { for (short i = 0; i < obj->vertices(); ++i)
305 for (short i = 0; i < obj->vertices(); ++i)
306 { if (i != 0) 304 { if (i != 0)
307 descr += ", "; 305 descr += ", ";
308 306
309 descr += obj->getVertex (i).stringRep (true); 307 descr += obj->getVertex (i).stringRep (true);
310 } 308 }
311 309 } break;
312 break;
313 310
314 case LDObject::Error: 311 case LDObject::Error:
315 descr = fmt ("ERROR: %1", obj->raw()); 312 { descr = fmt ("ERROR: %1", obj->raw());
316 break; 313 } break;
317 314
318 case LDObject::Vertex: 315 case LDObject::Vertex:
319 descr = static_cast<LDVertex*> (obj)->pos.stringRep (true); 316 { descr = static_cast<LDVertex*> (obj)->pos.stringRep (true);
320 break; 317 } break;
321 318
322 case LDObject::Subfile: 319 case LDObject::Subfile:
323 { LDSubfile* ref = static_cast<LDSubfile*> (obj); 320 { LDSubfile* ref = static_cast<LDSubfile*> (obj);
324 321
325 descr = fmt ("%1 %2, (", ref->fileInfo()->name(), 322 descr = fmt ("%1 %2, (", ref->fileInfo()->name(), ref->position().stringRep (true));
326 ref->position().stringRep (true)); 323
327 324 for (int i = 0; i < 9; ++i)
328 for (short i = 0; i < 9; ++i) 325 descr += fmt ("%1%2", ref->transform()[i], (i != 8) ? " " : "");
329 descr += fmt ("%1%2", ftoa (ref->transform() [i]),
330 (i != 8) ? " " : "");
331 326
332 descr += ')'; 327 descr += ')';
333 } 328 } break;
334 break;
335 329
336 case LDObject::BFC: 330 case LDObject::BFC:
337 descr = LDBFC::statements[static_cast<LDBFC*> (obj)->type]; 331 { descr = LDBFC::statements[static_cast<LDBFC*> (obj)->type];
338 break; 332 } break;
339 333
340 case LDObject::Overlay: 334 case LDObject::Overlay:
341 { LDOverlay* ovl = static_cast<LDOverlay*> (obj); 335 { LDOverlay* ovl = static_cast<LDOverlay*> (obj);
342 descr = fmt ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->camera()], 336 descr = fmt ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->camera()],
343 basename (ovl->filename()), ovl->x(), ovl->y(), ovl->width(), ovl->height()); 337 basename (ovl->filename()), ovl->x(), ovl->y(), ovl->width(), ovl->height());
344 } 338 }
345 break; 339 break;
346 340
347 default: 341 default:
348 descr = obj->typeName(); 342 { descr = obj->typeName();
349 break; 343 } break;
350 } 344 }
351 345
352 // Put it into brackets if it's hidden 346 // Put it into brackets if it's hidden
353 if (obj->hidden()) 347 if (obj->hidden())
354 descr = fmt ("[[ %1 ]]", descr); 348 descr = fmt ("[[ %1 ]]", descr);
358 352
359 // Color gibberish orange on red so it stands out. 353 // Color gibberish orange on red so it stands out.
360 if (obj->getType() == LDObject::Error) 354 if (obj->getType() == LDObject::Error)
361 { item->setBackground (QColor ("#AA0000")); 355 { item->setBackground (QColor ("#AA0000"));
362 item->setForeground (QColor ("#FFAA00")); 356 item->setForeground (QColor ("#FFAA00"));
363 } elif (lv_colorize && obj->isColored() && 357 }
364 358 elif (lv_colorize && obj->isColored() && obj->color() != maincolor && obj->color() != edgecolor)
365 obj->color() != maincolor && obj->color() != edgecolor)
366 { // If the object isn't in the main or edge color, draw this 359 { // If the object isn't in the main or edge color, draw this
367 // list entry in said color. 360 // list entry in said color.
368 LDColor* col = getColor (obj->color()); 361 LDColor* col = getColor (obj->color());
369 362
370 if (col) 363 if (col)
406 399
407 // Get the objects from the object list selection 400 // Get the objects from the object list selection
408 m_sel.clear(); 401 m_sel.clear();
409 const QList<QListWidgetItem*> items = ui->objectList->selectedItems(); 402 const QList<QListWidgetItem*> items = ui->objectList->selectedItems();
410 403
411 for (LDObject * obj : LDFile::current()->objects()) 404 for (LDObject* obj : LDFile::current()->objects())
412 for (QListWidgetItem * item : items) 405 for (QListWidgetItem* item : items)
413 { if (item == obj->qObjListEntry) 406 { if (item == obj->qObjListEntry)
414 { m_sel << obj; 407 { m_sel << obj;
415 break; 408 break;
416 } 409 }
417 } 410 }
418 411
419 // Update the GL renderer 412 // Update the GL renderer
420 for (LDObject * obj : priorSelection) 413 for (LDObject* obj : priorSelection)
421 { obj->setSelected (false); 414 { obj->setSelected (false);
422 m_renderer->compileObject (obj); 415 m_renderer->compileObject (obj);
423 } 416 }
424 417
425 for (LDObject * obj : m_sel) 418 for (LDObject* obj : m_sel)
426 { obj->setSelected (true); 419 { obj->setSelected (true);
427 m_renderer->compileObject (obj); 420 m_renderer->compileObject (obj);
428 } 421 }
429 422
430 m_renderer->update(); 423 m_renderer->update();

mercurial