model.cpp

changeset 23
69a91c1ff583
parent 22
335e430a6b4f
equal deleted inserted replaced
22:335e430a6b4f 23:69a91c1ff583
2 #include <stdlib.h> 2 #include <stdlib.h>
3 #include "common.h" 3 #include "common.h"
4 #include "io.h" 4 #include "io.h"
5 #include "gui.h" 5 #include "gui.h"
6 #include "draw.h" 6 #include "draw.h"
7 #include "bbox.h"
7 8
8 // Clear everything from the model 9 // Clear everything from the model
9 void closeModel () { 10 void closeModel () {
10 // Remove all loaded files and the objects they contain 11 // Remove all loaded files and the objects they contain
11 for (ushort i = 0; i < g_LoadedFiles.size(); i++) { 12 for (ushort i = 0; i < g_LoadedFiles.size(); i++) {
35 g_CurrentFile = f; 36 g_CurrentFile = f;
36 37
37 g_qWindow->R->hardRefresh(); 38 g_qWindow->R->hardRefresh();
38 } 39 }
39 40
41 void openModel (str zPath) {
42 if (g_CurrentFile)
43 closeModel ();
44
45 OpenFile* pFile = IO_OpenLDrawFile (zPath);
46 g_CurrentFile = pFile;
47
48 // Recalculate the bounding box
49 g_BBox.calculate();
50
51 // Rebuild the object tree view now.
52 g_qWindow->buildObjList ();
53 g_qWindow->setTitle ();
54 }
55
40 void saveModel () { 56 void saveModel () {
41 if (!g_CurrentFile) 57 if (!g_CurrentFile)
42 return; 58 return;
43 59
44 FILE* fp = fopen (g_CurrentFile->zFileName, "w"); 60 FILE* fp = fopen (g_CurrentFile->zFileName, "w");

mercurial