108 |
108 |
109 if (dlg->exec() == QDialog::Rejected) |
109 if (dlg->exec() == QDialog::Rejected) |
110 return; |
110 return; |
111 |
111 |
112 // Reinterpret it from the text of the input field |
112 // Reinterpret it from the text of the input field |
113 LDObject* newobj = ParseLine (ui.code->text()); |
113 currentDocument()->replaceWithFromString(obj, ui.code->text()); |
114 obj->replace (newobj); |
|
115 } |
114 } |
116 |
115 |
117 void AlgorithmToolset::makeBorders() |
116 void AlgorithmToolset::makeBorders() |
118 { |
117 { |
119 int count = 0; |
118 int count = 0; |
123 const LDObjectType type = object->type(); |
122 const LDObjectType type = object->type(); |
124 |
123 |
125 if (type != OBJ_Quad and type != OBJ_Triangle) |
124 if (type != OBJ_Quad and type != OBJ_Triangle) |
126 continue; |
125 continue; |
127 |
126 |
128 Model lines; |
127 Model lines {m_documents}; |
129 |
128 |
130 if (type == OBJ_Quad) |
129 if (type == OBJ_Quad) |
131 { |
130 { |
132 LDQuad* quad = static_cast<LDQuad*>(object); |
131 LDQuad* quad = static_cast<LDQuad*>(object); |
133 lines.emplace<LDLine>(quad->vertex (0), quad->vertex (1)); |
132 lines.emplace<LDLine>(quad->vertex (0), quad->vertex (1)); |
534 LDDocument* subfile = m_window->newDocument(); |
533 LDDocument* subfile = m_window->newDocument(); |
535 subfile->openForEditing(); |
534 subfile->openForEditing(); |
536 subfile->setFullPath(fullsubname); |
535 subfile->setFullPath(fullsubname); |
537 subfile->setName(LDDocument::shortenName(fullsubname)); |
536 subfile->setName(LDDocument::shortenName(fullsubname)); |
538 |
537 |
539 Model header; |
538 Model header {m_documents}; |
540 header.emplace<LDComment>(subtitle); |
539 header.emplace<LDComment>(subtitle); |
541 header.emplace<LDComment>("Name: "); // This gets filled in when the subfile is saved |
540 header.emplace<LDComment>("Name: "); // This gets filled in when the subfile is saved |
542 header.emplace<LDComment>(format("Author: %1 [%2]", m_config->defaultName(), m_config->defaultUser())); |
541 header.emplace<LDComment>(format("Author: %1 [%2]", m_config->defaultName(), m_config->defaultUser())); |
543 header.emplace<LDComment>("!LDRAW_ORG Unofficial_Subpart"); |
542 header.emplace<LDComment>("!LDRAW_ORG Unofficial_Subpart"); |
544 |
543 |
550 header.emplace<LDEmpty>(); |
549 header.emplace<LDEmpty>(); |
551 subfile->merge(header); |
550 subfile->merge(header); |
552 |
551 |
553 // Copy the body over to the new document |
552 // Copy the body over to the new document |
554 for (LDObject* object : selectedObjects()) |
553 for (LDObject* object : selectedObjects()) |
555 subfile->addObject(object->createCopy()); |
554 subfile->addFromString(object->asText()); |
556 |
555 |
557 // Try save it |
556 // Try save it |
558 if (m_window->save(subfile, true)) |
557 if (m_window->save(subfile, true)) |
559 { |
558 { |
560 // Save was successful. Delete the original selection now from the |
559 // Save was successful. Delete the original selection now from the |