129 void LDDocument::openForEditing() |
129 void LDDocument::openForEditing() |
130 { |
130 { |
131 if (m_isCache) |
131 if (m_isCache) |
132 { |
132 { |
133 m_isCache = false; |
133 m_isCache = false; |
134 print("Opened %1", name()); |
|
135 |
134 |
136 // Cache files are not compiled by the GL renderer. Now that this file is open for editing, it needs to be |
135 // Cache files are not compiled by the GL renderer. Now that this file is open for editing, it needs to be |
137 // compiled. |
136 // compiled. |
138 m_window->renderer()->compiler()->compileDocument(this); |
137 m_window->currentRenderer()->compiler()->compileDocument(this); |
139 m_window->updateDocumentList(); |
138 m_window->updateDocumentList(); |
140 } |
139 } |
141 } |
140 } |
142 |
141 |
143 bool LDDocument::isCache() const |
142 bool LDDocument::isCache() const |
175 if (not isCache()) |
174 if (not isCache()) |
176 { |
175 { |
177 m_isCache = true; |
176 m_isCache = true; |
178 print("Closed %1", name()); |
177 print("Closed %1", name()); |
179 m_window->updateDocumentList(); |
178 m_window->updateDocumentList(); |
180 |
179 emit closed(); |
181 // If the current document just became implicit(i.e. user closed it), we need to get a new one to show. |
|
182 if (currentDocument() == this) |
|
183 m_window->currentDocumentClosed(); |
|
184 } |
180 } |
185 } |
181 } |
186 |
182 |
187 LDGLData* LDDocument::glData() |
183 LDGLData* LDDocument::glData() |
188 { |
184 { |
597 { |
593 { |
598 history()->add(new AddHistoryEntry(objects().size(), obj)); |
594 history()->add(new AddHistoryEntry(objects().size(), obj)); |
599 m_objects << obj; |
595 m_objects << obj; |
600 addKnownVertices(obj); |
596 addKnownVertices(obj); |
601 obj->setDocument(this); |
597 obj->setDocument(this); |
602 m_window->renderer()->compileObject(obj); |
598 m_window->currentRenderer()->compileObject(obj); |
603 return getObjectCount() - 1; |
599 return getObjectCount() - 1; |
604 } |
600 } |
605 |
601 |
606 // ============================================================================= |
602 // ============================================================================= |
607 // |
603 // |
619 void LDDocument::insertObj(int pos, LDObject* obj) |
615 void LDDocument::insertObj(int pos, LDObject* obj) |
620 { |
616 { |
621 history()->add(new AddHistoryEntry(pos, obj)); |
617 history()->add(new AddHistoryEntry(pos, obj)); |
622 m_objects.insert(pos, obj); |
618 m_objects.insert(pos, obj); |
623 obj->setDocument(this); |
619 obj->setDocument(this); |
624 m_window->renderer()->compileObject(obj); |
620 m_window->currentRenderer()->compileObject(obj); |
625 |
621 |
626 |
622 |
627 #ifdef DEBUG |
623 #ifdef DEBUG |
628 if (not isCache()) |
624 if (not isCache()) |
629 dprint("Inserted object #%1(%2) at %3\n", obj->id(), obj->typeName(), pos); |
625 dprint("Inserted object #%1(%2) at %3\n", obj->id(), obj->typeName(), pos); |
684 m_objectVertices.remove(m_objects[idx]); |
680 m_objectVertices.remove(m_objects[idx]); |
685 m_objects[idx]->deselect(); |
681 m_objects[idx]->deselect(); |
686 m_objects[idx]->setDocument(nullptr); |
682 m_objects[idx]->setDocument(nullptr); |
687 obj->setDocument(this); |
683 obj->setDocument(this); |
688 addKnownVertices(obj); |
684 addKnownVertices(obj); |
689 m_window->renderer()->compileObject(obj); |
685 m_window->currentRenderer()->compileObject(obj); |
690 m_objects[idx] = obj; |
686 m_objects[idx] = obj; |
691 needVertexMerge(); |
687 needVertexMerge(); |
692 } |
688 } |
693 |
689 |
694 // ============================================================================= |
690 // ============================================================================= |
828 void LDDocument::addToSelection(LDObject* obj) // [protected] |
824 void LDDocument::addToSelection(LDObject* obj) // [protected] |
829 { |
825 { |
830 if (obj->isSelected() and obj->document() == this) |
826 if (obj->isSelected() and obj->document() == this) |
831 { |
827 { |
832 m_sel << obj; |
828 m_sel << obj; |
833 m_window->renderer()->compileObject(obj); |
829 m_window->currentRenderer()->compileObject(obj); |
834 } |
830 } |
835 } |
831 } |
836 |
832 |
837 // ============================================================================= |
833 // ============================================================================= |
838 // |
834 // |
839 void LDDocument::removeFromSelection(LDObject* obj) // [protected] |
835 void LDDocument::removeFromSelection(LDObject* obj) // [protected] |
840 { |
836 { |
841 if (not obj->isSelected() and obj->document() == this) |
837 if (not obj->isSelected() and obj->document() == this) |
842 { |
838 { |
843 m_sel.removeOne(obj); |
839 m_sel.removeOne(obj); |
844 m_window->renderer()->compileObject(obj); |
840 m_window->currentRenderer()->compileObject(obj); |
845 } |
841 } |
846 } |
842 } |
847 |
843 |
848 // ============================================================================= |
844 // ============================================================================= |
849 // |
845 // |
850 void LDDocument::clearSelection() |
846 void LDDocument::clearSelection() |
851 { |
847 { |
852 for (LDObject* obj : m_sel) |
848 for (LDObject* obj : m_sel) |
853 { |
849 { |
854 obj->deselect(); |
850 obj->deselect(); |
855 m_window->renderer()->compileObject(obj); |
851 m_window->currentRenderer()->compileObject(obj); |
856 } |
852 } |
857 |
853 |
858 m_sel.clear(); |
854 m_sel.clear(); |
859 } |
855 } |
860 |
856 |