src/file.cpp

changeset 381
241f65769a57
parent 379
f5f3faac60cd
child 383
10e60ae9ed58
equal deleted inserted replaced
380:e442d9b7c251 381:241f65769a57
24 #include <stdlib.h> 24 #include <stdlib.h>
25 #include "common.h" 25 #include "common.h"
26 #include "config.h" 26 #include "config.h"
27 #include "file.h" 27 #include "file.h"
28 #include "misc.h" 28 #include "misc.h"
29 #include "bbox.h"
30 #include "gui.h" 29 #include "gui.h"
31 #include "history.h" 30 #include "history.h"
32 #include "dialogs.h" 31 #include "dialogs.h"
33 #include "gldraw.h" 32 #include "gldraw.h"
34 33
448 f->setName (""); 447 f->setName ("");
449 f->setImplicit (false); 448 f->setImplicit (false);
450 g_loadedFiles << f; 449 g_loadedFiles << f;
451 setCurrentFile (f); 450 setCurrentFile (f);
452 451
453 g_BBox.reset();
454 g_win->R()->setFile (f); 452 g_win->R()->setFile (f);
455 g_win->fullRefresh(); 453 g_win->fullRefresh();
456 g_win->updateTitle(); 454 g_win->updateTitle();
457 f->history().updateActions(); 455 f->history().updateActions();
458 } 456 }
512 return; 510 return;
513 } 511 }
514 512
515 file->setImplicit (false); 513 file->setImplicit (false);
516 setCurrentFile (file); 514 setCurrentFile (file);
517
518 // Recalculate the bounding box
519 g_BBox.calculate();
520 515
521 // Rebuild the object tree view now. 516 // Rebuild the object tree view now.
522 g_win->fullRefresh(); 517 g_win->fullRefresh();
523 g_win->updateTitle(); 518 g_win->updateTitle();
524 g_win->R()->setFile (file); 519 g_win->R()->setFile (file);
809 PROP_NAME (objs) << obj; 804 PROP_NAME (objs) << obj;
810 805
811 if (obj->getType() == LDObject::Vertex) 806 if (obj->getType() == LDObject::Vertex)
812 PROP_NAME (vertices) << obj; 807 PROP_NAME (vertices) << obj;
813 808
814 if (this == currentFile())
815 g_BBox.calcObject (obj);
816
817 return numObjs() - 1; 809 return numObjs() - 1;
818 } 810 }
819 811
820 // ============================================================================= 812 // =============================================================================
821 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 813 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
822 // ============================================================================= 814 // =============================================================================
823 void LDOpenFile::insertObj (const ulong pos, LDObject* obj) { 815 void LDOpenFile::insertObj (const ulong pos, LDObject* obj) {
824 m_history.add (new AddHistory (pos, obj)); 816 m_history.add (new AddHistory (pos, obj));
825 m_objs.insert (pos, obj); 817 m_objs.insert (pos, obj);
826
827 if (this == currentFile())
828 g_BBox.calcObject (obj);
829 } 818 }
830 819
831 // ============================================================================= 820 // =============================================================================
832 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 821 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
833 // ============================================================================= 822 // =============================================================================
834 void LDOpenFile::forgetObject (LDObject* obj) { 823 void LDOpenFile::forgetObject (LDObject* obj) {
835 ulong idx = obj->getIndex (this); 824 ulong idx = obj->getIndex (this);
836 m_history.add (new DelHistory (idx, obj)); 825 m_history.add (new DelHistory (idx, obj));
837 m_objs.erase (idx); 826 m_objs.erase (idx);
838
839 // Update the bounding box
840 if (this == currentFile())
841 g_BBox.calculate ();
842 } 827 }
843 828
844 // ============================================================================= 829 // =============================================================================
845 bool safeToCloseAll () { 830 bool safeToCloseAll () {
846 for (LDOpenFile* f : g_loadedFiles) 831 for (LDOpenFile* f : g_loadedFiles)

mercurial